Reputation: 417
how can i write a select query by combining IN and LIKE i have a subquery which returns some records , with threse records i have to select records from another table. the problem is i have to use LIKE clause on the resultant recors of the subquery below is an example of what im trying to do
select * from salary where employeename like (select name from employee)
from salary table i need records which matches the name of employe table. i need to use LIKE . can someone help me please
Upvotes: 6
Views: 29844
Reputation: 37398
I'd go with a join
instead of an in
... although with the wildcards it will be a full table-scan anyways:
select distinct s.*
from salary s
join employee e on s.employeename like '%' + e.name + '%'
Upvotes: 24