List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:November 25 2007 4:34am
Subject:Re: Default result
View as plain text  
In the last episode (Nov 24), Steffan A. Cline said:
> Is there anything I am missing that will allow me to return a default row if
> the sought after row is not found?
> 
> For example :
> 
> Select * from table1 where column1=1234
> 
> If 1234 is not found, row1 would be returned instead.
> If 1234 is found then that is the row returned.

SELECT * FROM (
 SELECT * FROM table1 WHERE column1=1234
  UNION
 SELECT * FROM table1 WHERE column1=1 /* or whatever uniquely identifies row1 */
) t LIMIT 1;

-- 
	Dan Nelson
	dnelson@stripped
Thread
Default resultSteffan A. Cline25 Nov
  • Re: Default resultDan Nelson25 Nov