什么是在mysql中连接表的正确方法

时间:2010-03-06 08:46:47

标签: mysql

如何让这个SQL查询工作:

SELECT student.LASTNAME,
       student.FIRSTNAME,
       student.IDNO,
       student.YEAR,
       parents.P_ADDRESS
FROM student
WHERE P_ADDRESS="Ambagat, Santol, LU"
RIGHT JOIN parents ON student.IDNO = parents.IDNO

我只想在关节上添加where语句。因为w3schools中的常见示例不包含where语句。请帮忙。

1 个答案:

答案 0 :(得分:3)

喜欢这个

SELECT  student.LASTNAME, 
        student.FIRSTNAME, 
        student.IDNO, 
        student.YEAR, 
        parents.P_ADDRESS 
FROM    student RIGHT JOIN parents  ON  student.IDNO=parents.IDNO 
                                    AND P_ADDRESS="Ambagat, Santol, LU"