Reputation: 4462
I am complete newbie when it comes to MySQL. I have done some searching around here and elsewhere, but haven't been able to work out something that I imagine is very simple.
I have an email program that imports fields/columns from a MySQL database for bulk emails.
I am wanting to only import information for users that have a particular value in a particular column in a table.
To import all users I would normally use:
SELECT firstname, email FROM users
I have tried amending this to:
SELECT firstname, email FROM users WHERE group = "test"
where group
is the name of the column that I am trying to test against, and test
is the value I am searching for. I think this might be close, but it brings up an error.
Could someone put me straight?
Upvotes: 0
Views: 238
Reputation: 1998
I think your problem is that group is a keyword in MySQL. You can use
SELECT firstname, email FROM users WHERE `group` = "test"
Use back ticks to quote field names.
Upvotes: 4