user225269
user225269

Reputation: 10913

What's the proper way of joining tables in mysql

How do I get to make this sqsl query work:

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

I just want to add where statement on the joins. Because the usual example in w3schools doesn't include a where statement. Please help.

Upvotes: 0

Views: 85

Answers (1)

Adriaan Stander
Adriaan Stander

Reputation: 166486

Like this

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" 

Upvotes: 3

Related Questions