MySQL query with unacceptable word...help!
Posted: Thu Jul 21, 2005 11:12 am
Hi,
I'm having trouble with a query and hope someone knows how to get around my problem. I have a database with information stored for each month of the year. My columns are named "jan, feb, mar,...,nov, dec". Trouble is that "dec" already has a meaning in mysql as a synonym for "DECIMAL". When I try to query "dec" I get a syntax error.
I know that I could simply rename the column, but that throws a small twig into the machine and I'd like to avoid doing as such. Is there any way of disguising the column name "dec" so that mysql doesn't think I mean "decimal"?
In case there's any confusion, here's a snippet of my code...
Thanks in advance.
I'm having trouble with a query and hope someone knows how to get around my problem. I have a database with information stored for each month of the year. My columns are named "jan, feb, mar,...,nov, dec". Trouble is that "dec" already has a meaning in mysql as a synonym for "DECIMAL". When I try to query "dec" I get a syntax error.
I know that I could simply rename the column, but that throws a small twig into the machine and I'd like to avoid doing as such. Is there any way of disguising the column name "dec" so that mysql doesn't think I mean "decimal"?
In case there's any confusion, here's a snippet of my code...
Code: Select all
$sql="SELECT oct,nov,dec FROM datatable WHERE id=$id";
$result= mysql_query($sql, $conn);
$row= mysql_select_row($result);