Strange query results

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Elias Alhanatis
    New Member
    • Aug 2007
    • 56

    Strange query results

    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='LA TIN_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
  • Niheel
    Recognized Expert Moderator Top Contributor
    • Jul 2005
    • 2432

    #2
    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='L ATIN\_2A'"

    If that doesn't work, there's probably something up with your data. The rest of your query looks good.
    niheel @ bytes

    Comment

    • patjones
      Recognized Expert Contributor
      • Jun 2007
      • 931

      #3
      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

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Run this and post the results here
        Code:
        SELECT Lesson_Id, Lesson_Name
        FROM Lesson_Names
        WHERE Lesson_Name='LATIN_2A'

        Comment

        • Elias Alhanatis
          New Member
          • Aug 2007
          • 56

          #5
          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...

          Comment

          • patjones
            Recognized Expert Contributor
            • Jun 2007
            • 931

            #6
            I'm not sure if it helps, but it does appear that "_" is indeed a wildcard in MySQL: http://lists.mysql.com/mysql/186085.

            Comment

            Working...