PDA

View Full Version : Can someone explain this SQL error


vindaloo
07-10-2003, 09:20 AM
Hi,

I'm getting an error with a SELECT statement that I don't understand.

I have a table called prices where the first 2 fields are called group and type, which are character fields.

This statement does not work:
SELECT * FROM prices WHERE group = 'p'
This statement works:
SELECT * FROM prices WHERE type = 'C150'
This statement also works (the difference from the first example being that group is enclosed in ``)
SELECT * FROM prices WHERE `group` = 'p'
Can anyone explain this? The PHP tutorial I'm following does not use the quotes around the field name in the WHERE clause. I've been using SQL for years (under SAP R/3 ABAP) and have never come across this before.

I'm sure it's a simple error but it's been driving me mad!!!

Many thanks in advance,
Vindaloo.

vindaloo
07-11-2003, 12:22 AM
Renaming the field to GROUPID appears to have done the trick!

Thanks very much David.

Just out of interest, I tried this in a SAP R/3 system, and it wouldn't let me define a table field called GROUP as it is a reserved word.

Regards,
Vindaloo