Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 Two Conditions with Equal and Like

Author  Topic 

Dasman
Yak Posting Veteran

79 Posts

Posted - 2011-06-13 : 13:30:00
Say I wanted only events under the recordingID = 10 and where EventType would be a certain text like "Mixed".

So far my code looks like this:

SELECT * FROM myTABLE
WHERE
(RecordingID = 10 AND
EventType LIKE '%Mixed%')

This currently yields no results when I know there are results. Why doesnt an equal condition and LIKE condition play nice in SQL?

Dasman

==========================
Pain is Weakness Leaving the Body.

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-06-13 : 13:33:53
>> I know there are results
>> This currently yields no results

It's because one of these is incorrect.
note - both conditions need to be true on a row for that row to be returned.


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Dasman
Yak Posting Veteran

79 Posts

Posted - 2011-07-14 : 11:27:21
Hello Nigel,

You're right. I looked at my data - RID 10 doesnt have any %mixed%. I thought I was querying wrong.

Thanks,
Dasman

==========================
Pain is Weakness Leaving the Body.
Go to Top of Page
   

- Advertisement -