List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:November 4 2004 7:16am
Subject:Re: field name (1 and 2) causes error
View as plain text  
In the last episode (Nov 04), Louie Miranda said:
> I did create a table and a fieldname of 1 and 2. when i did enter
> this query to insert on my sql, it causes error.
> 
> insert into rates_fedex (weight_kg,a,b,c,d,e,f,g,h,1,2) values **
> 
> error: ERROR 1064: You have an error in your SQL syntax.  Check the
> manual that corresponds to your MySQL server version for the right
> syntax to use near '1,2) values
> (".5","10.4","17.33","19.64","21.42","22.58","24.26
> 
> How do we insert properly something on a field with that the name is
> numbers? or that aint right, im wrong.

Put backtics around any table or field name that might be misparsed by
mysql.  This lets you use numbers, spaces, or even reserved words:

insert into rates_fedex (weight_kg,a,b,c,d,e,f,g,h,`1`,`2`) values
 
If you look at the queries generated by myodbc, you'll see this a lot
(it plays safe and quotes everything)

-- 
	Dan Nelson
	dnelson@stripped
Thread
field name (1 and 2) causes errorLouie Miranda4 Nov
  • Re: field name (1 and 2) causes errorDan Nelson4 Nov
    • Re: field name (1 and 2) causes errorLouie Miranda4 Nov