PDA

View Full Version : Select statement syntax



lphillippi
10-13-2003, 10:41 PM
What is the proper syntax for the where clause of a select statement? I get an error when executing the query below when I add the where statement. I've checked the mysql documentation and they don't show an example using a string value. How do I encapsulate a string? Single quotes? Double quotes?


SELECT name FROM `product_groups` WHERE group = 'hpp'

You have an error in your SQL syntax near 'GROUP = 'hpp' LIMIT 0, 30' at line 1

jalal
10-14-2003, 01:17 AM
Possibly because GROUP is an SQL keyword?

Try enclosing `group` in backquotes like the table name.

FZ
10-14-2003, 03:23 AM
Jalal is right: I just tested this and it does look like GROUP is a keyword. In fact, it didn't even let me create the table at all. And single quotes work just fine for strings...

lphillippi
10-14-2003, 07:45 PM
Thank you. This resolved the problem.