April 28, 2010 at 1:46 am
I've written the following stored procedure, but it doesn't work how I would like it too, could one of you experts cast an eye over it and tell me what I'm doing wrong please
select * from resource where [date] > '02/02/2010' and [Alan] like 'In%' or [Alan] like 'R%'
basically I need to get all instances from the field Alan which contains either 'In' or has 'R' at the start of the field after a certain date, if I use
select * from resource where [date] > '02/02/2010'
this works as expected, or if I use
select * from resource where [Alan] like 'In%' or [Alan] like 'R%'
that also works, but if I use the Query in full it returns everything I need except it also returns entries before the specified date. I'd be very gratfull if someone can help
April 28, 2010 at 3:18 am
Use parenthesis around the two LIKE conditions:
select *
from resource
where [date] > '02/02/2010'
and ( [Alan] like 'In%' or [Alan] like 'R%' )
-- Gianluca Sartori
April 28, 2010 at 3:34 am
Gianluca Sartori (4/28/2010)
Use parenthesis around the two LIKE conditions:
select *
from resource
where [date] > '02/02/2010'
and ( [Alan] like 'In%' or [Alan] like 'R%' )
Thats great, works a treat, thanks Gianluca
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply