* gregory lefebvre > I try to translate in MySQL language a problem which I mean is a UML > partition constraint. > > > I explain: > > There is a table A binded with a table B. > This table B is itself binded according to a B.P parameter: > either to a table C > either to a table D > but never to both. > > I think one solution should be to do a first SELECT on B in order to > determine B.P. Thus I should do again a SELECT on the 3 tables according > to the B.P in the WHERE clause. > > BUT I would like to do a one time SELECT on A->B->C or A->B->D. > I cannot translate this constraint in SQL for MySQL. > > Could someone who unsderstood this incomprehensible description > help me. ;o)
Have you tried something like this: SELECT A.*,B.*,IF(B.BP='C',C.data,D.data) as "C or D" FROM A LEFT JOIN B ON B.AID=A.AID LEFT JOIN C ON C.BID=B.BID AND B.BP = 'C' LEFT JOIN D ON D.BID=B.BID AND B.BP = 'D' WHERE ... I think it should solve your problem. HTH, -- Roger --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php