5 Replies Latest reply on Dec 16, 2013 9:46 AM by kaostika

    SQL Child records

    kaostika

      Hi, I am trying to get a set of ID's with all their children.

       

      So we have 3 tables. STATE (1 record) < CITY( 3 records ) < ADDRESS ( 9 records )

       

      I want to see the ID like this

       

      IDstate (record 1)

      IDcity (record 1)

      IDaddress (record 1)

      IDaddress (record 2)

      IDaddress (record 3)

      IDcity (record 2)

      IDaddress (record 4)

      IDaddress (record 5)

      IDaddress (record 6)

      IDcity (record 3)

      IDaddress (record 7)

      IDaddress (record 8)

      IDaddress (record 9)

       

       

       

      ExecuteSQL ( "

       

       

      SELECT S.IDstate , C.IDstate , A.IDadress

      FROM address AS A

      JOIN address AS A on A.IDcity = C.IDcity

      JOIN city AS C on C.IDcity = S.IDstate

      WHERE S.IDstate = ?

       

       

      " ; " " ; "" ; GLOBAL::ID.state )