Reputation: 4343
I have a table with friend1, friend2 and request, basically the end of the statement im trying to only output rows where the request is equal to p ... But it seems to be giving me an error instead.
My query is as follows:
SELECT * FROM friends WHERE friendfrom=8 OR friendto=8 AND request=p
The error message im getting is as follows:
Unknown column 'p' in 'where clause'
Can anyone please give me a bit of help ... Im quite stumped on this.
Upvotes: 0
Views: 50
Reputation: 8629
If you dont write a string into single or double quote then it will treated as a column name of your table. that's why you have above error. so replace your query with this one:=
SELECT * FROM friends WHERE friendfrom=8 OR friendto=8 AND request='p';
Upvotes: 0
Reputation: 230461
Is p
a string? You probably want this:
SELECT * FROM friends WHERE friendfrom=8 OR friendto=8 AND request='p';
Upvotes: 0
Reputation: 17560
p is a literal, you need to use '
marks to show that:
SELECT *
FROM friends
WHERE friendfrom = 8
OR friendto = 8
AND request = 'p'
Upvotes: 2