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 protected]'
INNER JOIN
accounts a ON u.userId = a.userId
INNER JOIN
appointments ap ON u.userId = ap.userId;
CodePudding user response:
Your query syntax sequence is wrong. If you want to JOIN any table it should come after your parent table.
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 protected]';
Check on https://www.w3schools.com/mysql/mysql_join.asp
CodePudding user response:
Your JOIN
statements go before the WHERE
clause:
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 protected]';