Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I query all records from table A and similar matches from table B as a boolean in a different column

I am trying to query from tables A and B that returns all the records from table A and indicates matches (ID’s that exist in both tables) as true in a field called "approved"

TABLE A

ID
2
4
6
8
10

TABLE B

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

ID
2
6
8

WHAT I TRIED

This returns the results times the number of records in table B, but is of course not what I am looking for.

SELECT [Source A].ID, IIf([Source A].[ID]=[Source B].[ID],True,False) AS approved
FROM [Source A], [Source B];

DESIRED RESULT

ID MATCH
2 TRUE
4
6 TRUE
8 TRUE
10

>Solution :

You can try in this way

SELECT table_a.ID, IIf(table_a.[ID]=table_b.[ID],'True','False') AS approved
FROM table_a
LEFT JOIN table_b ON table_a.id = table_b.id

It will then show true and false accordingly

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading