I am trying to get data from the database like that, but i have this error how can i fix?
SELECT post.text,users.name,users.surname,users.profile_id,post.post_id,comments.text as comment,
(SELECT user.name, user.surname FROM users user WHERE profile_id = comments.profile_id) as name_comment
FROM post
INNER JOIN users ON users.profile_id = post.profile_id
INNER JOIN comments ON comments.profile_post = post.post_id
Your subquery:
has 2 fields instead one
You can:
Use 2 distinct subquery to get user.name and user.surname;
concatenate the two information so you have one output field;
Why you use subquery when you have joined your users table in the main query (with the same condition)