Jump to content

query finds same report 4 times


SirChick

Recommended Posts

I have a query which loads up a list in order of two groups... this is sort what it does:

 

Say you have a list of reports in a database.. each report has chat logs and these are on a different table.

Now what im trying to do is order them firstly so that the users that are not staff are the priority in the list and then the staff, and then that is ordered by time ASC like so:

 

User - 3 days ago

User - 2 days ago

User - 2 minutes ago

Staff - 10 days ago

Staff - 7 days ago

 

You see what i mean ?

 

$GetAppeals = mysql_query("(SELECT * FROM `reportsituation` a LEFT JOIN `staff` b 
ON a.SaidBy != b.UserID ORDER BY a.SaidBy, a.Saidtime) UNION ALL 
(SELECT * FROM `reportsituation` c LEFT JOIN `staff` d ON c.SaidBy=d.UserID 
ORDER BY a.SaidBy, a.Saidtime)")
or die(mysql_error()); 

 

EDIT:

 

Ok just updating this as i fixed the error but its coming out in my while loop 4 times rather than just the once. For one of the records. I think its looping it for every 1 message that has occured in the chatlogs for the report and there are 4 in total so its showing it 4 times.

 

Link to comment
https://forums.phpfreaks.com/topic/84159-query-finds-same-report-4-times/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.