Helpful Information
 
 
Category: PHP / MySQL
Select statement syntax

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

Possibly because GROUP is an SQL keyword?

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

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...

Thank you. This resolved the problem.










privacy (GDPR)