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
 Transact-SQL (2005)
 LIKE question

Author  Topic 

Mondeo
Constraint Violating Yak Guru

287 Posts

Posted - 2010-08-03 : 05:14:47
Hi,

I'm trying to combine a LIKE clause with a subquery

WHERE v.vehicletxt LIKE (SELECT TOP 1 cvehicle_shortmodtext FROM PUB_CAR..capvehicles WHERE cvehicle_modtext = 'A3 CABRIOLET')

I want the LIKE to have wildcards at each site, i.e. '%value%', how can I do this with the returned value of the subquery

Thanks

Kristen
Test

22859 Posts

Posted - 2010-08-03 : 05:22:29
WHERE v.vehicletxt LIKE '%' + (SELECT TOP 1 cvehicle_shortmodtext FROM PUB_CAR..capvehicles WHERE cvehicle_modtext = 'A3 CABRIOLET') + '%'
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-08-03 : 05:23:17
or

WHERE v.vehicletxt LIKE (SELECT TOP 1 '%' + cvehicle_shortmodtext + '%' FROM PUB_CAR..capvehicles WHERE cvehicle_modtext = 'A3 CABRIOLET')
Go to Top of Page

Mondeo
Constraint Violating Yak Guru

287 Posts

Posted - 2010-08-03 : 05:33:37
Thanks :)
Go to Top of Page
   

- Advertisement -