Sunday, March 11, 2012

compare results of 2 subqueries

i want to compare the results of 2 subqueries... something similar to this:
subquery1 IN subquery2

i cant use the IN unless subquery1 returns a single value i want to compare multiple results like for example:
('name1','name2') in ('name1','name2','name3') returns true

how can i acheive this?

thanks--Something like this

select
Result=
case when not exists(
select *
from pubs.dbo.titleauthor titleauthor
where authors.au_id=titleauthor.au_id
)
then 'false'
else 'true'
end
,*
from pubs.dbo.authors authors|||thanks for the reply

i want to know if a set of words which i get from my app are included in the list of words i get from the database.
do u suggest i insert these words in a temp table then use the query as u suggested or is there another way where i dont have to create a table.

thank you|||You can select from everything, but it would be much simpler, if table is in database.|||Thank you

since am building the sql query from my app it easier to select the values i have as they are without adding a new table.

No comments:

Post a Comment