Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have one database test.db, in this db file two tables are present info1 and info2.

info1 data
id |name |gender
----------------
1 |A |male
2 |B |male
3 |C |female
4 |D |male

info2| data
-----------
id | marks
1 | 90
3 | 85


So, now I want get result like,
compare | id | name | gender
--------------------------
true | 1 | A | male
false | 2 | B | male
true | 3 | C | female
false | 4 | D | male


How to write query for this?
Posted
Updated 8-Jan-15 1:11am
v2

1 solution

Considering info1 is your mail table to which you are comparing and wants the result.

SQL
Select case when i2.id is null then 'false' else true end as 'compare',
i1.id,i1.name,i1.gender
from info1 i1 left outer join info2 i2
on i1.id = i2.id
 
Share this answer
 
v2
Comments
Member 10168792 8-Jan-15 7:26am    
thank u
Praveen Kumar Upadhyay 8-Jan-15 7:26am    
Welcome.

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



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