While the subject sounds counter-intuitive, I think I'm trying to do something simple 
and I can't figure it out.

I have a simple table, "lookup", with two columns, id and decode. I want to write a 
simple query that retrieves the decode if there, and the id if the row is missing for 
a given literal id.

So after several iterations I tried:
"select distinct ifnull(a.decode,333) from lookup a right outer join lookup b on 
a.id=b.id and b.id=333;"

This works if the key is not found, but when the key is found I get two rows back 
(both the id and the decode).

I feel like I'm making this too complicated...is there an easier way to do this with a 
single statement?

Thx,
R



---------------------------------------------------------------------
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

Reply via email to