homepage Welcome to WebmasterWorld Guest from 54.205.189.156
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

    
ORDER problem.
Could be a quickie
ahmedtheking




msg:3561994
 3:11 pm on Jan 30, 2008 (gmt 0)

Just a quick one, I have two cols: Hierarchy, IdHierarchy

Hierarchy is like 1,2,3,...,n that's relative to IdHierarchy that's like 1.2.3, 1.2.4, 1.2.5, 1.2.n

I've like MySQL to sort my query by IdHierarchy first and then order by Hierarchy for each group (in a sense).

 

stajer




msg:3562106
 5:15 pm on Jan 30, 2008 (gmt 0)

Does mysql support left()?

ORDER BY left(heriechyID,1), heirarchy

LifeinAsia




msg:3562116
 5:25 pm on Jan 30, 2008 (gmt 0)

ORDER BY left(heriechyID,1), heirarchy

But ordering by just the first character won't guarantee that 1.2.3 will come before 1.2.4.

I'm not quite sure of what the OP means. Can you post a short example of what you'd like the sorted data to look like?

ahmedtheking




msg:3562209
 7:06 pm on Jan 30, 2008 (gmt 0)

I decided to restructure the database and changed a few things. It's all working now. I now have ParentHierarchy (n.n.n ...), Hierarchy (n.n.n ...) and IdHierarchy (id.id.id ...). This allows me to ORDER BY Hierarchy (because that's an absolute hierarchy where before was relative to the level as defined in IdHierarchy).

jtara




msg:3562217
 7:08 pm on Jan 30, 2008 (gmt 0)

Yea, I'm afraid I don't get it either. Just what is it that you are trying to do? I think you need to back-up a bit and tell us what you are trying to accomplish.

(Oops, we crossed posts.)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved