MySQL Forums
Forum List  »  PHP

Re: need help in creating a joined query
Posted by: Peter Brawley
Date: October 05, 2018 11:37AM

> The user.user_id table ia a primary one

Apparently user.user_id is a column, not a table (tables can't be "primary" in the relational database sense).

> user.uname is kind of primary

No more possible than "kind of pregnant".

> select DISTINCTROW up.*,g.* ,cu.*, ...

Who can read values from all columns in ten tables!? Select specific columns.

The query does not aggregate. In a Group By query, values returned for columns that are neither Grouped By nor aggregated are arbitrary. What are you trying to accomplish with Group By?

...from a left join b... is used if and only if the joining column(s) can be null in b. Your ...group_posts as g left join user... is suspicious. If group_posts can have authors with no user_ids, the database design is incorrect, and if they can't then the join should be inner. Ditto for other joins from user.

Let's see the Create Table SQLcmds, the query requirement (succinctly), and just enough sample data to give rise to a meaningful query result.

Edited 2 time(s). Last edit at 10/05/2018 11:38AM by Peter Brawley.

Options: ReplyQuote

Written By
Re: need help in creating a joined query
October 05, 2018 11:37AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.