Welcome to WebmasterWorld Guest from 54.196.232.162

Forum Moderators: open

Message Too Old, No Replies

ORDER problem.

Could be a quickie

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 12, 2004
posts: 789
votes: 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).

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

Full Member

10+ Year Member

joined:Nov 3, 2003
posts:324
votes: 0


Does mysql support left()?

ORDER BY left(heriechyID,1), heirarchy

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

Moderator from US 

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 10, 2005
posts:5551
votes: 24


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?

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 12, 2004
posts: 789
votes: 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).
7:08 pm on Jan 30, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member jtara is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 26, 2005
posts:3041
votes: 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.)

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members