DEV Community

Abkabane
Abkabane

Posted on

Any help with MySQL?

Hi, community
I need your assistance in MySQL databases query to retrieve some data.

In the attached photo, there are 2 sets of tables that I am retrieving data from it using inner join statement.

I can add data and retrieve it nicely.

The problem arises when I ADD more than one row of data from the same user, I think my query just only one set of a row from the second table.

I will have everything in terms of the post content except the data from the second table, the field I want return only one row all the field for that user.

My query statement

SELECT * FROM tbl_samples_post
INNER JOIN tbl_twitter_user ON tbl_twitter_user.user_id = tbl_samples_post.user_id
LEFT JOIN tbl_follow ON tbl_follow.sender_id = tbl_samples_post.user_id
RIGHT JOIN recording ON recording.user_id = tbl_samples_post.user_id
WHERE tbl_follow.receiver_id = '".$_SESSION["user_id"]."' OR tbl_samples_post.user_id = '".$_SESSION["user_id"]."'
GROUP BY tbl_samples_post.post_id
ORDER BY tbl_samples_post.post_id DESC

                    --end--
Enter fullscreen mode Exit fullscreen mode

Top comments (0)