Thread: How I write pretty query

How I write pretty query

From
Rado Petrik
Date:

Hi , 


I have table 

------------------
id     |  name 
------------------
1         rado 
2         marek
3         pista 

I need make query. Your output is only (true or false) 

This 2 query are good but no pretty.

1)      SELECT COUNT(*) FROM table WHERE name=rado 
                       -------------       output    -->   COUNT(*)   1 

or 

2)      SELECT name FROM table WERE name=rado        
                       -------------       output    -->   name   rado 





and this is pretty query :-) buy no good.
       SELECT (true or false) FROM table WHERE name=rado
                       --------------       output ---->        true 

How I write good and pretty query ? 

Thanks 

Rado 



Re: How I write pretty query

From
Stephan Szabo
Date:
On 29 Apr 2003, Rado Petrik wrote:

> I have table
>
> ------------------
> id     |  name
> ------------------
> 1         rado
> 2         marek
> 3         pista
>
> I need make query. Your output is only (true or false)

If you don't specifically care about the string true/false and
just want a boolean, probably something like:select exists (select * from tab where name='rado');


If you really want the particular strings, use a case, something like:select case when exists(select * from tab where
name='rado')then 'true' else 'false' end;