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

Heroku

Deploy with ease. Manage efficiently. Scale faster.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (0)

ACI image

ACI.dev: Fully Open-source AI Agent Tool-Use Infra (Composio Alternative)

100% open-source tool-use platform (backend, dev portal, integration library, SDK/MCP) that connects your AI agents to 600+ tools with multi-tenant auth, granular permissions, and access through direct function calling or a unified MCP server.

Check out our GitHub!