多个INNER JOIN SQL访问语法

时间:2016-02-07 12:43:28

标签: mysql

我正在尝试使用table(six_attendance, five_attendance)通过INNER JOINtable(users)获取数据。这是我尝试过的:

$query = mysql_query("SELECT * 
FROM
(users 
INNER JOIN six_attendance 
ON users.username = six_attendance.username)
INNER JOIN five_attendance 
ON users.username = five_attendance.username
WHERE six_attendance.username OR five_attendance.username ='$reg_no'");

1 个答案:

答案 0 :(得分:0)

$query = mysql_query("SELECT * 
FROM
users 
INNER JOIN six_attendance 
ON users.username = six_attendance.username
INNER JOIN five_attendance 
ON users.username = five_attendance.username
WHERE six_attendance.username='$reg_no' OR five_attendance.username ='$reg_no'");