SQL AND operator not working properly
- by Chandana De Silva
I have following two tables
LandParcels Table
Blockid ParcelNo storPri
======= ======== =======
52000105 3 State
52000105 4 Private
52000105 5 State
Actions Table
Blockid ParcelNo ActionTaken
======= ======== ===========
52000105 3 Received
52000105 3 Send to Computer
52000105 4 Received
52000105 5 Received
I want to find the records Received but not Send to Computer
Here is my query
select
l.blockid, l.parcelno
from
landparcels l
left join
actions ac on l.blockid = ac.blockid and l.parcelno = ac.parcelno
where
ac.actiontaken = 'Received'
and ac.actiontaken <> 'Send to Computer'
and ac.blockid = 52000105
The result is
Blockid ParcelNo
======= ========
52000105 3
52000105 4
52000105 5
I want ParcelNo 4 and 5