Click to See Complete Forum and Search --> : What's wrong with this SQL command?
ozpo1
03-20-2006, 04:12 PM
I'm running this command:
Set objRS = objConn.Execute("SELECT * FROM " & dbcategory & " WHERE area = '"& areaobjRS &"';")
and getting the following error:
"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 '900 WHERE area = 'la1'' at line 1"
Anyone knows what's the problem?
Thanks in advanced, Oz.
chrismartz
03-20-2006, 06:03 PM
This should work:
Set objRS = objConn.Execute("SELECT * FROM " & dbcategory & " WHERE area = '"& areaobjRS &"'")
If you do not have a table called '900' in your database, the SQL will fail.
ozpo1
03-21-2006, 10:30 AM
I found out that the problem is that the name of my table is a number- 900.
I tried to changed the name of the table to a string and than it works. However....
My problem is that I need to have the names of my tables as numbers because this is how I know where to search in them.
Is there any way to save the number into a variable and to be able to proccess the request? When I'm using my PHPadmenstrator it's working, so it's just a matter of how I write it in ASP, RIGHT?
This is what I mean:
session("dbcategory")=??? something like '900' or "900" (both of them doesn't work)
and then the sql command:
Set objRS = objConn.Execute("SELECT *FROM " & session("dbcategory") & ";")
Thanks in advanced, Oz.
chrismartz
03-21-2006, 05:40 PM
For this, you can do [900].
Seems to me that naming tables numerically is not a great idea.
ozpo1
03-24-2006, 11:13 PM
Thanks for the help.
From one hand, using numeric for table names seems to be a bad idea, but from the other it is very simple to find the right table by using a simple calculation that determine what table to call and this is why I choose it.