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

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay