Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- f.*,
- m.*
- FROM
- students st
- LEFT JOIN parents f ON f.id = st.f_id
- LEFT JOIN parents m ON m.id = st.m_id
- WHERE
- st.id = 333
- SELECT
- st.*
- FROM
- parents p
- LEFT JOIN students st ON (p.id = st.f_id OR m.id = st.m_id)
- WHERE
- p.id = 333
- SELECT
- sibl.*
- FROM
- students st
- LEFT JOIN students sibl ON (sibl.f_id = st.f_id OR sibl.m_id = st.m_id)
- WHERE
- st.id = 333
Add Comment
Please, Sign In to add comment