Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2003
    Posts
    15

    Unanswered: 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

  2. #2
    Join Date
    Dec 2002
    Location
    Czech Republic
    Posts
    249

    Re: compare results of 2 subqueries

    --Something like this
    Code:
    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

  3. #3
    Join Date
    Jan 2003
    Posts
    15
    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

  4. #4
    Join Date
    Dec 2002
    Location
    Czech Republic
    Posts
    249
    You can select from everything, but it would be much simpler, if table is in database.

  5. #5
    Join Date
    Jan 2003
    Posts
    15
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •