By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,964 Members | 1,318 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,964 IT Pros & Developers. It's quick & easy.

Strange query results

Elias Alhanatis
P: 56
Hello!
I have a table with a column called "Lesson_Names",varchar type.
The following query :
"SELECT Lesson_Id FROM Lesson_Names WHERE Lesson_Name='LATIN_2A' "
returns 2 IDs instead of 1 ( the IDs of "LATIN_2A" and of "LATIN_2B" ) .
Is there something i am doing wrong?

Thank you in advance ,

Elias
Sep 18 '11 #1
Share this Question
Share on Google+
5 Replies


Expert Mod 100+
P: 2,324
The only thing i can think of is maybe the underscore is being interpreted as a wildcard. But that's only supposed to happen when you use LIKE.

Just incase, try using "Lesson_Name='LATIN\_2A'"

If that doesn't work, there's probably something up with your data. The rest of your query looks good.
Sep 27 '11 #2

patjones
Expert 100+
P: 931
I'm replying to this just because I would like to know what the answer is in case you do indeed find the answer! The query looks good to me as well...

Pat
Sep 28 '11 #3

Rabbit
Expert Mod 10K+
P: 12,347
Run this and post the results here
Expand|Select|Wrap|Line Numbers
  1. SELECT Lesson_Id, Lesson_Name
  2. FROM Lesson_Names
  3. WHERE Lesson_Name='LATIN_2A'
Sep 28 '11 #4

Elias Alhanatis
P: 56
I managed to bypass the error using "LATIN_TWO_A" and "LATIN_TWO_B",
but it still appears when using greek letters:

Query:
SELECT Lesson_Id, Lesson_Name
FROM Lesson_Names
WHERE Lesson_Name='ΛΑΤΙΝ_2Α'

Results:
154 ΛΑΤΙΝ_2Α
155 ΛΑΤΙΝ_2Β

Indeed the underscore is some kind of wildcard , but
the results it yelds are not clear...
Sep 29 '11 #5

patjones
Expert 100+
P: 931
I'm not sure if it helps, but it does appear that "_" is indeed a wildcard in MySQL: http://lists.mysql.com/mysql/186085.
Sep 30 '11 #6

Post your reply

Sign in to post your reply or Sign up for a free account.