# question

## Write a Query

Hi, Find the Attachment ![alt text][1] This Question was asked by interview. Any one Can answer this question Write Query B shaded Area? [1]: /storage/temp/1559-b+shaded+area.jpg
b shaded area.jpg (34.6 KiB)

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Like 1 ·
SELECT * FROM [Table B] WHERE Shaded=1; #geek
1 Like 1 ·

·
SELECT * FROM TableA RIGHT OUTER JOIN TableB ON TableA.name = TableB.name WHERE TableA.id IS null THIS is the answer

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Logically what area is defined by the shading on TableB? Just defining the logical will lead you to several possible solutions to writing a query. It's everything from TableB that doesn't match anything in TableA. From there, could you write a query?

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sure it's possible. Looks like you have it figured out. It's all about figuring out the logic needed to eliminate matching values in TableB and only return non-matching. NOT EXISTS will work. As will an OUTER JOIN.
1 Like 1 ·
Hi Grant Fritchey Here Table A join Table B but we have to write a query to get B records but not matching Table A record. Is it possible to write query?
0 Likes 0 ·
Can we use NOT EXISTS or Except Operator or RIGHT OUTER JOIN in our Case?
0 Likes 0 ·
1 comment

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks FatherJack So below is the answer after saw your Link Isnt? SELECT * FROM TableA RIGHT OUTER JOIN TableB ON TableA.name = TableB.name WHERE TableA.id IS null
0 Likes 0 ·
SELECT * FROM B EXCEPT SELECT * FROM A