faqts : Computers : Databases : MySQL : Connectivity : MyODBC

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

11 of 20 people (55%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

Why do I keep getting the error "invalid column name" in ODBC queries?
Should I use double or single quotes to enclose data in ODBC queries?
Why does my query work if I execute it directly, but not work through ODBC?

May 11th, 2000 16:51
Nathan Wallace, Paul Smith, Jeremy Cole


I have two tables, products and trolley.  I want to select all the
trolley items where the trolley code="ZYX" and pull the description from
the products table into the query.  I have a unique number that links
the tables.

I've tried the following;

  SELECT * from trolley, products
  WHERE trolley.linktoproducts=products.counter AND trolley.code="ZYX"

This works directly, but through ODBC comes up with the error

  invalid column name "ZYX"

You need to try the query using single quotes instead of double quotes.

  SELECT * from trolley, products
  WHERE trolley.linktoproducts=products.counter AND trolley.code='ZYX'