Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Select Statement with In and Like

$
0
0

I would like to find out how to use both keywords IN AND LIKE in a select statement or maybe another way to work around.  Here is the scenario.  I need to get data from a table including last name O'Donnell.  When I just did a simple select statement such as "Select * from tbl1 where LastName Like 'O''Donnell%', I'm able to get the record.  But if I have a more complicated query such as "select distinct LN from tbl2 where LN in (select LastName from tbl1 where Active = 1) order by LN", then the name O'Donnell is missing.  I also tried EXISTS and INNER JOIN between the tables.  The name still didn't show.

Please help!  Thank you!

Jenny


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>