I want to update a column in myTable.  The value this column is set to depends on a nested select statement which sometimes returns 0 rows instead of 1.  This is a problem since the column I'm trying to update is set to refuse nulls.  Here's a sample:

update myTable set myColumn = (Select altColumn from altTable where altColumn != 'XXX' limit 1) where myColumn = 'XXX';

MyColumn cannot accept nulls, but sometimes "Select altColumn ..." returns 0 rows, and thus, the query fails. 

Is there a way to set a default value to be inserted into myColumn if and when "select altColumn ..." returns zero rows?

Mark
begin:vcard
fn:Mark Fenbers
n:Fenbers;Mark
org:DoC/NOAA/NWS/OHRFC
adr:;;1901 South SR 134;Wilmington;OH;45177-9708;USA
email;internet:[EMAIL PROTECTED]
title:Sr. HAS Meteorologist
tel;work:937-383-0430 x246
x-mozilla-html:TRUE
url:http://weather.gov/ohrfc
version:2.1
end:vcard

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Reply via email to