List:General Discussion« Previous MessageNext Message »
From:Thiru Date:February 16 2001 1:31am
Subject:Re: If, then, else . . .
View as plain text  
Hi,

U can do nested ifs in Mysql.
I am not sure if there is a limit in the no of levels it can go upto.

If U R going to do this for 1000's of records there may be a slight drop in performance.

SELECT field1, if(field1="a",100,if(field1="b",200,"ERROR")) FROM table;

will do perfect.

Cheers!

Thiru

On Thu, 15 Feb 2001 16:32:25 -0700
John Halladay <John.halladay@stripped> wrote:

-> If I am querying a field that has either "a" or "b" as a value and I want a
-> second field's value to be dependant on the first field's value, how would I
-> right that?
-> 
-> SELECT field1, IF(field1="a",100,IF(field1="b",200,"ERROR") FROM table;
-> 
-> The IF,THEN,ELSE is the only thing I can think of, but that is the Excel,
-> Access side of my brain talking.  Sorry for the basis question.  Any help
-> would be much appreciated.
-> 
-> Thanks.
-> 
-> John H.
-> 
-> ---------------------------------------------------------------------
-> 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 <mysql-thread65432@stripped>
-> To unsubscribe, e-mail
<mysql-unsubscribe-thiru=infoseek.co.jp@stripped>
-> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
-> 
-> 

‚¨”æ‚ê—l‚Å‚·B
‚æ‚낵‚ã‚­I
---------------------------
  ƒT[ƒrƒXŠJ”­•” 
  ƒpƒeƒB@(a) ƒeƒBƒ‹
  “àü|2402
---------------------------
Thread
If, then, else . . .John Halladay16 Feb
  • Re: If, then, else . . .Thiru16 Feb
RE: If, then, else . . .Quentin Bennett16 Feb