Use coalesce() as in where clause

This is a discussion on Use coalesce() as in where clause within the PHP Language forums, part of the PHP Programming Forums category; I've a query like this: select coealesce(table1.code1, table2.code1) as mycode from... where mycode = 'XXX' But this ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-21-2005
Bob Bedford
 
Posts: n/a
Default Use coalesce() as in where clause

I've a query like this:

select coealesce(table1.code1, table2.code1) as mycode
from...
where mycode = 'XXX'

But this query fails. Unknow column mycode in where clause.

why ??? "coalesce() as" doesn't work ?

Bob

Reply With Quote
  #2 (permalink)  
Old 02-21-2005
Matt Mitchell
 
Posts: n/a
Default Re: Use coalesce() as in where clause


"Bob Bedford" <bedford1@notforspammershotmail.com> wrote in message
news:42199b3f$0$3412$5402220f@news.sunrise.ch...
: I've a query like this:
:
: select coealesce(table1.code1, table2.code1) as mycode
: from...
: where mycode = 'XXX'
:
: But this query fails. Unknow column mycode in where clause.
:
: why ??? "coalesce() as" doesn't work ?

select coalesce(table1.code1, table2.code1) as mycode
from ...
where coalesce(table1.code1, table2.code1) = 'XXX';


OR

select coalesce(table1.code1, table2.code1) as mycode
from ...
where table1.code1='XXX' or table2.code1 = 'XXX';

I think the second might be faster...

Matt


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 10:51 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0