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.
| Author |
Topic |
|
ronstone
Starting Member
32 Posts |
Posted - 2002-05-10 : 17:50:32
|
| I have a query which compares a column to a group (select statement).Example:SELECT * FROM CarsRec WHERE BrandName IN (SELECT BrandName FROM BrandRec)But I need to use a Like, because in BrandRec, some BrandNames will contain Ma% or Fo% in addition to Ford and Mazda.How do I:SELECT * FROM CarsRec WHERE BrandName LIKE (SELECT BrandName from BrandRec)???Hope that is a good picture,Ron |
|
|
VyasKN
SQL Server MVP & SQLTeam MVY
313 Posts |
Posted - 2002-05-11 : 07:39:04
|
| Try this:SELECT * FROM CarsRec c WHERE EXISTS ( SELECT 1 FROM BrandRec b WHERE b.BrandName LIKE LEFT(c.BrandName, 2) + '%') Next time please post table structures, sample data and desired output, so that it's easier for us to work on it.--HTH,Vyashttp://vyaskn.tripod.com |
 |
|
|
|
|
|