pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How I write pretty query.
3+ messages / 3 participants
[nested] [flat]

* How I write pretty query.
@ 2003-04-29 15:49  Radovan Petrikí <r.petrik@episoftware.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Radovan Petrikí @ 2003-04-29 15:49 UTC (permalink / raw)
  To: pgsql-sql

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 




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* How I write pretty query
@ 2003-04-29 17:46  Rado Petrik <r.p@szm.sk>
  0 siblings, 1 reply; 3+ messages in thread

From: Rado Petrik @ 2003-04-29 17:46 UTC (permalink / raw)
  To: pgsql-sql



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 




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How I write pretty query
@ 2003-04-29 17:55  Stephan Szabo <sszabo@megazone23.bigpanda.com>
  parent: Rado Petrik <r.p@szm.sk>
  0 siblings, 0 replies; 3+ messages in thread

From: Stephan Szabo @ 2003-04-29 17:55 UTC (permalink / raw)
  To: Rado Petrik <r.p@szm.sk>; +Cc: pgsql-sql


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;




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2003-04-29 17:55 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-04-29 15:49 How I write pretty query. Radovan Petrikí <r.petrik@episoftware.com>
2003-04-29 17:46 How I write pretty query Rado Petrik <r.p@szm.sk>
2003-04-29 17:55 ` Re: How I write pretty query Stephan Szabo <sszabo@megazone23.bigpanda.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox