-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Em 14-06-2014 07:39, Kenneth escreveu:
> Hi,
> 
> I have a table that contains 5 items. Usually I order them by product name. 
> Now
> I'd like to order them so a specific ID is first and then the rest. As
> everything else is ready I'm looking into making the SQL query do the 
> ordering.
> 
> I found a posting (
> https://groups.google.com/forum/?fromgroups#!searchin/web2py/orderby$20$20case/web2py/B9iM-r1rV0A/jPMBmoSv2kgJ
> ) where CASE was used with orderby but I just couldn't understand how to get 
> it
> working.
> 
> Is this the way or is there an other way to do this?
> 
> 

I would suggest adding an extra field to the table to hold the display order and
use it in the 'orderby' parameter.

Otherwise, if your DBMS supports it you may use the order by/case approach or a
left join, as described in here:
http://stackoverflow.com/questions/6332043/sql-order-by-multiple-values-in-specific-order

- -- 
Com os melhores cumprimentos,

Carlos Correia
=========================
MEMÓRIA PERSISTENTE
Tel.: 219 291 591 - GSM:  917 157 146 / 967 511 762
e-mail: ge...@memoriapersistente.pt - URL: http://www.memoriapersistente.pt
Jabber: m...@jabber.org
GnuPG: wwwkeys.eu.pgp.net
URL Suporte: https://t5.m16e.com/gps
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlOcVfMACgkQ90uzwjA1SJWfQgCeM4rb56JxCgaemjt3Ntjt7ZIy
k7kAoIyNZmaN/cYku1VwG4OQT5jFWYMU
=Zz5I
-----END PGP SIGNATURE-----

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to