Click here to Skip to main content
15,892,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI Everyone

I need help with Sql query


select * from country where country = 'india' (they bith are same table)
and not exists
select * from country were country='Nepal'


Please can some one help me to get the distinct records(which are not there in 2nd query but exists in 1st query) .

When I am executing this its returning me no values.
Actually I should return the values which are not in the second query.


Thanks
Posted

try this

SQL
if exists (select * from country  where country ='india')
select * from country  where country ='india'
else 
select * from country were country='Nepal'
 
Share this answer
 
why can't you simply use this:
SQL
select * from country where country = 'india' AND country <> 'Nepal'

OR
SQL
select * from country where country = 'india' AND country !='Nepal'
 
Share this answer
 
v2
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900