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

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

While many AI coding tools operate as simple command-response systems, Qodo Gen 1.0 represents the next generation: autonomous, multi-step problem-solving agents that work alongside you.

Read full post

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

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

Okay