RE: mysql and order in a query

2002-04-06 Thread Roger Baklund

* Paul DuBois
 At 18:03 +0200 4/6/02, David yahoo wrote:
  Is there any way to put a sort order different than the
  alpahbetical order in string.
 
 A thing like that order french,german 


 ORDER BY ELT(language,'english','german','french'),Linkname ASC

Maybe you meant FIELD(language...?

From the manual:

Changes in release 3.20.17
--
[...]
   * The `ELT()' function is renamed to `FIELD()'.  The new `ELT()'
 function returns a value based on an index: `FIELD()' is the
 inverse of `ELT()' Example: `ELT(2,A,B,C)' returns `B'.
 `FIELD(B,A,B,C)' returns `2'.

The language column is a string containing 'english', 'french' or 'german'.

The order of the fields in the FIELD() should be the order of what you want
as a result:  'french','german','english' will give you 'french' items
first, 'english' items last. Beware that any item with a language not
existing in the field list will get a zero value, and be sorted first.

--
Roger
query


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: mysql and order in a query

2002-04-06 Thread David yahoo

I think of a little hack
I can add in where clause something like :

ELT(language,'english','german','french') != 0

to avoid language not in list even if there no normally :)
I try this as soon as i can.

thanks.


 * Paul DuBois
  At 18:03 +0200 4/6/02, David yahoo wrote:
   Is there any way to put a sort order different than the
   alpahbetical order in string.
  
  A thing like that order french,german 
 
 
  ORDER BY ELT(language,'english','german','french'),Linkname ASC

 Maybe you meant FIELD(language...?

 From the manual:

 Changes in release 3.20.17
 --
 [...]
* The `ELT()' function is renamed to `FIELD()'.  The new `ELT()'
  function returns a value based on an index: `FIELD()' is the
  inverse of `ELT()' Example: `ELT(2,A,B,C)' returns `B'.
  `FIELD(B,A,B,C)' returns `2'.

 The language column is a string containing 'english', 'french' or
'german'.

 The order of the fields in the FIELD() should be the order of what you
want
 as a result:  'french','german','english' will give you 'french' items
 first, 'english' items last. Beware that any item with a language not
 existing in the field list will get a zero value, and be sorted first.

 --
 Roger
 query


 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)

 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail
[EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: mysql and order in a query

2002-04-06 Thread Paul DuBois

At 18:28 +0200 4/6/02, Roger Baklund wrote:
* Paul DuBois
  At 18:03 +0200 4/6/02, David yahoo wrote:
   Is there any way to put a sort order different than the
   alpahbetical order in string.
  
  A thing like that order french,german 


  ORDER BY ELT(language,'english','german','french'),Linkname ASC

Maybe you meant FIELD(language...?

Right.  Thanks.




From the manual:

Changes in release 3.20.17
--
[...]
* The `ELT()' function is renamed to `FIELD()'.  The new `ELT()'
  function returns a value based on an index: `FIELD()' is the
  inverse of `ELT()' Example: `ELT(2,A,B,C)' returns `B'.
  `FIELD(B,A,B,C)' returns `2'.

The language column is a string containing 'english', 'french' or 'german'.

The order of the fields in the FIELD() should be the order of what you want
as a result:  'french','german','english' will give you 'french' items
first, 'english' items last. Beware that any item with a language not
existing in the field list will get a zero value, and be sorted first.

--
Roger
query


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php