Sql Statement for joins one to many - TechRepublic
Question
April 30, 2009 at 07:36 PM
winn67257

Sql Statement for joins one to many

by winn67257 . Updated 17 years, 2 months ago

TableA

AId AName
—————
1 AbC
2 Atable
3 ABus

TableB

BId BName
—————-
20 Bac
21 Bqw
22 Bws
23 Bqs

Table C

CId AId BId
———————
1 1 20
2 1 21
3 1 22
4 2 20
5 2 21
6 3 23
7 3 21

Let put it this way

AId BId
1 20,21,22,23
2 20,21
3 23,21

Forevery AId, there can be multiple BIds associated to it. So From UI Only the BID’s will be send to the database. What I need to know is If the combination of BIds already associated to AID or it exists in the database. If they exist we need to send true or else we need to send false. say for this combination

BIDs

20,22 return false
20,21 return true
20,21,22 return false
23,21 return true

Any Ideas..

Thanks

This discussion is locked

All Comments