vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Got a tough one here for you SQL junkies. I'm working on a website (in ASP) for a national greek/college organization. All it's college chapters have greek chapter names, i.e. Alpha Chapter, Delta Chapter, Delta Iota Chapter, Gamma Phi Chapter, ect. ect. I need the SQL to return the chapters in greek alphabet ordering. See below: 1. Alpha 2. Beta 3. Gamma 4. Delta 5. Epsilon 6. Zeta 7. Eta 8. Theta 9. Iota 10. Kappa 11. Lambda 12. Mu 13. Nu 14. Xi 15. Omicron 16. Pi 17. Rho 18. Sigma 19. Tau 20. Upsilon 21. Phi 22. Chi 23. Psi 24. Omega Basically I need a way to specify this type of presedence for wording and keep all the results in greek-letter order, so Sigma Upsilon comes before Sigma Tau, and so on. Also, to make it even more difficult, these are written words, not the actual greek symbols like α β etc. Everything is stored in the DB as Alpha Beta Whateva Chapter. Hopefully some of you SQL junkies will be able to help on this one |
| |||
| Create a table with the required mapping, i.e the greek letter and its precedence. CREATE TABLE Mappings ( Greek VARCHAR(10) NOT NULL, Precedence INT NOT NULL PRIMARY KEY) ; Now, you can use this table in your queries with a join on the Greek column & then sort the resultset by precedence. SELECT * FROM tbl INNER JOIN Mappings ON tbl.Greekletter = Mappings.Greek ORDER BY Mappings.Precedence ; -- - Anith ( Please reply to newsgroups only ) |
| ||||
| I'm pretty sure that this won't work. I believe it assumes that the field name consists only of one greek letter, and that the precendence (sort_order) will be matched along with the mapping letter by letter for each record in the column. This would have been great, except the records in the CHAPTERS table are more like: 'Gamma Rho Chapter', 'Xi Chapter', 'Sigma Epsilon Chapter', ect. I do appreciate the attempt though. "Anith Sen" <anith@bizdatasolutions.com> wrote in message news:<T8jMa.31826$0v4.2329012@bgtnsc04-news.ops.worldnet.att.net>... > Create a table with the required mapping, i.e the greek letter and its > precedence. > > CREATE TABLE Mappings ( > Greek VARCHAR(10) NOT NULL, > Precedence INT NOT NULL PRIMARY KEY) ; > > Now, you can use this table in your queries with a join on the Greek column > & then sort the resultset by precedence. > > SELECT * > FROM tbl > INNER JOIN Mappings > ON tbl.Greekletter = Mappings.Greek > ORDER BY Mappings.Precedence ; |