0

Have 2 tables TABLE1 and TABLE2

Have to fetch record from both table in below given 2 criteria with INNER JOIN.

[1] Fetch record from when TABLE1.id = TABLE2.id [2] Fetch record from when TABLE1.id NOT IN TABLE2.id field 

CAN any one tell query for both criteria.

Edit:

table1

id 1 2 3 

table2

id 1 2 

result for criteria 1

1, 2

result for criteria 2

3

1
  • No I am facing this issue in my application Commented Jan 20, 2011 at 9:36

1 Answer 1

1

1)

SELECT * FROM [Table1] INNER JOIN [Table2] On [Table1].[ID]=[Table2].[ID] 

2)

SELECT * FROM [table1] LEFT JOIN [Table2] ON [Table1].[ID]=[Table2].[ID] WHERE [Table2].[ID] IS NULL 

EDIT: Tested option 2 and it works as expected

Sign up to request clarification or add additional context in comments.

8 Comments

No it is not working ...see my post update to get better understanding of my post
Do you mean they are one query and not two?
Please have a look at my post again ...i have added example
Im getting the output you provided. Are you getting an error or something?
I am getting 0 records in 2 criteria
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.