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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.