Here's how I did it....

SQL> select cat.*, (select count(faq.cat_id) from mdfaq_faq_cat faq
  2  where cat.id = faq.cat_id and faq.faq_id = 23) as selected from
mdfaq_category cat;

        ID NAME
---------- ----------------------------------------------------------------
  SELECTED
----------
         6 Solid Edge
         0

         7 MicroStation
         1

        10 MDSync
         1

Thx for your help.
Barry

"Barry Prentiss" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi,
>  Here's another SQL query problem:
>
> How do I construct a query that returns 1 if a value is present and zero
if
> it is not, for a list of values returned in another query?
>
> i.e. select a.id, a.name, c.selected from table-with-id-and-name a,
>     (select 1 as selected from another-table b if a.id = b.id
>      or select 0 as selected from another-table b if a.id != b.id ) c;
>
>  Thx in Advance,
>  Barry Prentiss
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to