I need to select data from 2 tables in my DB - comments and users. This is the structure of these tables:
comments:
commentID | commentDateAndTime | imageID | userID | comment
users:
userID | username
I need to select all the data in both tables, join it on userID, where imageID should be equal to $imageID
. I tried the following SELECT
statement:
return json_encode(select("
SELECT
commentDateAndTime,
imageID,
userID,
COMMENT,
username
FROM users
JOIN comments
ON comments.userID = users.userID
WHERE comments.imageID = $imageID
GROUP BY comments.comment
"));
But I didn't receive any data.
Any advice, please?