Issue selecting two rows from two columns

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • johnjr
    New Member
    • Jul 2007
    • 4

    Issue selecting two rows from two columns

    I'm trying to select two rows from two columns and while I can select the columns, the selection of multiple rows is not falling into place. I can pull one row into the report, but not two.

    This is what I'm writing

    SELECT name, number FROM table
    WHERE name="variable1 ',''variable2'

    Something is occurring around the , between variable1 and variable2. I know I doing something wrong, but can't figure it out. I can pull variable1 by itself just fine.

    The specific error is:
    sql: errorYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 'variable2' at line 2
    number: 1064

    Any ideas would be greatly appreciated. I tried searching and could not find an answer to this problem.
  • johnjr
    New Member
    • Jul 2007
    • 4

    #2
    Found the answer

    SELECT name, number FROM table
    WHERE name IN('var1', 'var2', 'var3')

    Comment

    • sumitbatra1981
      New Member
      • Aug 2007
      • 4

      #3
      SELECT name, number FROM table
      WHERE name in('variable1', 'variable2')

      Comment

      Working...