Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I'm trying to create an sql query using an inner join but I'm getting a syntax error for my first inner join statement

SELECT u.userId, u.firstName, u.lastName, u.emailAddress, u.phoneNumber, ap.date, ap.time, a.balance 
FROM users u WHERE u.firstName = 'first_name' AND u.lastName = 'last_name' AND u.emailAddress = 'email@gmail.com' 
INNER JOIN accounts a ON u.userId =  a.userId 
INNER JOIN appointments ap ON u.userId = ap.userId;

>Solution :

Your query syntax sequence is wrong. If you want to JOIN any table it should come after your parent table.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

SELECT u.userId, u.firstName, u.lastName, u.emailAddress, u.phoneNumber, ap.date, ap.time, a.balance 
FROM users u 
INNER JOIN accounts a ON u.userId = a.userId 
INNER JOIN appointments ap ON u.userId = ap.userId
WHERE u.firstName = 'first_name' AND u.lastName = 'last_name' AND u.emailAddress = 'email@gmail.com';

Check on https://www.w3schools.com/mysql/mysql_join.asp

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading