Forget PHP right now. This is your SQL query:
SELECT pageID, pageCategoryID, 'order', title FROM pages WHERE pageCategoryID='1' AND 'order'='2'
In SQL, like in many other languages, you use quotation marks to enter literals. Since the string 'order'
will never be equal to the string '1
', your query will always return zero rows, regardless of other values.
If order
is the name of a column, you cannot quote it.
Now, given that order
is a reserved word , you will have to use inverse elements around it. You can also enter integers as integers (no need to quote them):
SELECT pageID, pageCategoryID, `order`, title FROM pages WHERE pageCategoryID=1 AND `order`=2
source share