Reputation: 61
Iam having trouble creating a query. How to i create two where selects in one?
select * from messages where id ='1' and where recd = '0'
thanks
Upvotes: 0
Views: 107
Reputation: 573
If id and recd fields are numeric values you can/should avoid using '(single quot) for better index searching performance.
select * from messages where id = 1 and recd = 0;
MySQL is enough advanced to manage this string/numeric conversion in both current case of query.
Hope this will helpful.
Upvotes: 1
Reputation: 13465
TRy this::
select * from messages where id ='1' and recd = '0'
Upvotes: 1
Reputation: 263703
use one WHERE
clause only and the conditions are separated by AND/OR
depending on your needs.
SELECT *
FROM messages
WHERE id ='1' AND recd = '0'
Upvotes: 6