If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > How to get the correct result from mysql?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-04-10, 17:38
sql_er sql_er is offline
Registered User
 
Join Date: Jan 2007
Posts: 48
How to get the correct result from mysql?

Hi,

I ran into the following problem when I select from a table:

SELECT name FROM X WHERE name = 'Vina Concha y Toro';

I get 2 results back:

1. Vina Concha y Toro
2. Viņa Concha y Toro

The 2nd result seems to have a non-english character (i.e. ņ), but mysql does not seem to distinguish between the two results.

I checked the 'name' column of table X and the collation is 'latin1_swedish_ci'. I initially assumed that this was the problem. I then created table Y with collation 'utf8_general_ci' for 'name' column and inserted both results there [not sure if this was a correct choice, but assumed that utf8 should be a catch all case?]. When I repeated the query, I got the exact same results back. So, this does not seem to have solved the problem.

Can someone please suggest what I can do to only get 'Vina Concha y Toro' when I do:

SELECT name FROM X WHERE name = 'Vina Concha y Toro';

and only get 'Viņa Concha y Toro' when I do:

SELECT name FROM X WHERE name = 'Viņa Concha y Toro';


Thanks a lot!
Reply With Quote
  #2 (permalink)  
Old 11-04-10, 20:50
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by sql_er View Post
Can someone please suggest what I can do ...
sure

use the BINARY operator

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 11-05-10, 18:03
sql_er sql_er is offline
Registered User
 
Join Date: Jan 2007
Posts: 48
How to get the correct result from mysql?

Quote:
Originally Posted by r937 View Post
sure

use the BINARY operator

Hi, thanks for the advice!

I just did the following, as you suggested:

SELECT BINARY Name FROM Table X
WHERE Name = 'Viņa Concha y Toro';

and only got 1 correct result and when I tried with the other string I got 1 correct result as well.

This was run against the original table where each column has collation 'latin1_swedish_ci'.

My question now is - do I have to use BINARY word before the name every time I do the query to make sure mysql returns single correct result or is there a way to change character set/collation at the table/column level so that when I just do regular SELECT with an equal sign, it returns the correct result?

Also, it looks like when I use BINARY, case sensitivity is turned on. That is not preferable. I need to be able to do case insensetive search, but be able to differentiate between english and non-english characters.

Is this possible in mysql?

Thank you very much!
Reply With Quote
  #4 (permalink)  
Old 11-05-10, 18:38
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by sql_er View Post
Also, it looks like when I use BINARY, case sensitivity is turned on. That is not preferable. I need to be able to do case insensetive search...
oh, sorry

then i am lost...
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 11-05-10, 22:24
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
Maybe you could jurry-rig something using MySQL :: MySQL 5.1 Reference Manual :: 11.9 Full-Text Search Functions ???

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On