user2028990
user2028990

Reputation: 61

2 where statements in mysql query

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

Answers (3)

Ronak Vyas
Ronak Vyas

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

Sashi Kant
Sashi Kant

Reputation: 13465

TRy this::

select * from messages where id ='1' and recd = '0'

Upvotes: 1

John Woo
John Woo

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

Related Questions