Reputation: 33
I have a small query that uses 'And' once with 'Or' twice, as soon as I add the second Or it returns all data, not the filtered. Basically the below should return all cases for John Smith where status is either 'Active' or 'In Contact'
Select
c.Adviser,
l.Status
From
tbl_lead l Inner Join
tbl_clients c On c.client_id = l.client_id
Where
(c.Adviser = 'John Smith' And l.Status = 'active') Or
(l.Status = 'in contact')
Can anyone see where I am going wrong at all?
Upvotes: 2
Views: 52
Reputation: 411
Use "IN"
clause.
Select
c.Adviser,
l.Status
From
tbl_lead l Inner Join
tbl_clients c On c.client_id = l.client_id
Where
c.Adviser = 'John Smith' And l.Status IN ('active','in contact')
Upvotes: 4