dbTalk Databases Forums  

MySQL ORDER BY question

comp.databases comp.databases


Discuss MySQL ORDER BY question in the comp.databases forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Leigh Riley
 
Posts: n/a

Default MySQL ORDER BY question - 08-06-2003 , 09:35 AM






Hi there,

I wonder if someone can help me. I have 3 columns in my table - DATE,
DOCUMENT, and SUBDOCUMENT. Each document has 4 different sub-documents.
Is there a MySQL query that will allow me to get all the information
from this table ordered by Document (alphabetically), and then by
subdocument listing design, code, inspection, and test in that order?

E.g.

DATE DOCUMENT SUBDOCUMENT
Jul 31st test1 design
Jul 31st test1 code
Jul 31st test1 inspection
Jul 31st test1 test
Jul 31st test2 design
Jul 31st test2 code
Jul 31st test2 inspection
Jul 31st test2 test
^ ^
Quote:
`- always this order

`- alphabetically


Thanks in advance for any replies!

- Best regards,

Leigh



Reply With Quote
  #2  
Old   
programmer
 
Posts: n/a

Default Re: MySQL ORDER BY question - 08-07-2003 , 05:05 AM






create a SubdocumentOrder table:

create table SubdocumentOrder(SortSeq int, SubDocument char(64));

insert into SubdocumentOrder values(1, 'design');
insert into SubdocumentOrder values(2, 'code');
insert into SubdocumentOrder values(3, 'inspection');
insert into SubdocumentOrder values(4, 'test');

Then join it with the main table, with one of the sort keys being SortSeq.



Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.