A question about complex SQL statement

Posted by william on Stack Overflow See other posts from Stack Overflow or by william
Published on 2010-03-20T14:20:34Z Indexed on 2010/03/20 14:31 UTC
Read the original article Hit count: 382

Filed under:
|

Table A has columns ID and AName, Table B has columns BName and ID.

B.ID is foreign key of A.ID.

Write a SQL statement to show data like: print column AName and C which describe whether Table B has ID in Table A, if exists 1 or else 0.

So if A is:

1 aaa
2 bbb

B is:

something,2

output is:

aaa,0
bbb,1

© Stack Overflow or respective owner

Related posts about sql

Related posts about query