如何仅从'list'表中获取行。不是父母的表

时间:2014-01-16 04:56:12

标签: php mysql

我只想从'list'表中显示行。但是下面的代码也提供了来自父表的行值

        mysqli_query($con, "select * from list
        RIGHT JOIN department ON list.department_id = department.id
        RIGHT JOIN subject ON list.subject_id = subject_id
        RIGHT JOIN sub_subject ON list.sub_subject_id = sub_subject_id
        order by list.id $order");

1 个答案:

答案 0 :(得分:1)

    mysqli_query($con, "select list.* from list
    Left JOIN department ON list.department_id = department.id
    Left JOIN subject ON list.subject_id = subject_id
    Left JOIN sub_subject ON list.sub_subject_id = sub_subject_id
Where department.id = NULL
And subject_id = NULL
And  sub_subject_id = NULL
order by list.id $order");