If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > How *not to* use SELECT DISTINCT

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-15-07, 02:38
Frunkie Frunkie is offline
Gives Bad Advice
 
Join Date: Mar 2007
Location: 010101010110100
Posts: 791
How *not to* use SELECT DISTINCT

Hello all,

I have an issue that I can't solve. I was using SELECT DISTINCT but I think there may be a better way of doing this. Below is some of my sample data.
Quote:
Laundry Room - (East) Tuesday 00:00:00 06:00:00

Laundry Room - (East) Wednesday 00:00:00 06:00:00

Utility Room - (East) Thursday 00:00:00 06:00:00

Utility Room - (East) Friday 00:00:00 06:00:00

Gym - (East) Saturday 00:00:00 06:00:00
This data comes from 4 different tables. After joining them all together, I would like to sort the data by the first field which indicates the room type then have all of the times and days under that. As you can see, I have "Laundry Room" 2x. Here is what I am trying to achive.

Quote:
Laundry Room East

Tuesday 00:00:00 06:00:00

Wednesday 00:00:00 06:00:00

Thursday 00:00:00 06:00:00

Friday 00:00:00 06:00:00

Gym
Saturday 00:00:00 06:00:00

Sunday 00:00:00 06:00:00
EDIT: I forgot to mention that that first field (Gym, Laundry room) is data within the field that can be added by the user dynamically. If that data was always the same and never changed, it would be easy. I could just specify exactly what I needed through a select. I hope I am making sense here.

Can someone please point me in the direction I should go with this?

Thanks,

Frank

Last edited by Frunkie; 08-15-07 at 02:45.
Reply With Quote
  #2 (permalink)  
Old 08-15-07, 06:15
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
do this with your application script

it requires merely ORDER BY, not GROUP BY

GROUP BY is for collapsing multiple rows of a group into one result row
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 08-15-07, 06:53
Frunkie Frunkie is offline
Gives Bad Advice
 
Join Date: Mar 2007
Location: 010101010110100
Posts: 791
Quote:
Originally Posted by r937
do this with your application script

it requires merely ORDER BY, not GROUP BY

GROUP BY is for collapsing multiple rows of a group into one result row
Ok Rudy, thanks. I figured that it may need to be done in my application but I was hoping for an sql fix. Thanks again.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On