From: | Gurudutt <guru(at)indvalley(dot)com> |
---|---|
To: | Haller Christoph <ch(at)rodos(dot)fzk(dot)de> |
Cc: | pgsql-sql(at)postgresql(dot)org, pgsql-php(at)postgresql(dot)org |
Subject: | Re: [SQL] Joins!! |
Date: | 2001-11-17 04:10:58 |
Message-ID: | 112294515.20011117094058@indvalley.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-php pgsql-sql |
Hello Haller,
Thanks for the reply, although I found a peculiar bug in PhpPgAdmin
(Ver: 2.2.1),the web client for postgres. It used to escape the "+" operator
everytime I used it, but then tried the same query in psql, it
worked!!
I have two tables
1. tickettab
2. ticketmultab
Both the tables have arrivaldate and arrivaltime as fields
I want to sort the combination of the result set, like
suppose an entry exists in tickettab as 2001-11-12 12:30
and the next entry in tickettab is 2001-11-12 16:40
if there exists a entry in ticketmultab as 2001-11-12 13.30
then I should get the results as follows
ticketid arrival date arrival time
1 2001-11-12 12:30:00 -- tickettab entry
2 2001-11-12 13:30:00 --ticketmultab entry
3 2001-11-12 16:40:00 -- tickettab entry
so depending on the arrival date and arrival time I need the result
set to be sorted.
I used bubble sort in php by moving the result set into an array and
then sorting it. Is there any other way to do this thru SQL.
--
Best regards,
Gurudutt mailto:guru(at)indvalley(dot)com
Life is not fair - get used to it.
Bill Gates
Wednesday, November 14, 2001, 4:05:24 AM, you wrote:
>>
>> Q 1. Consider the following query, suppose I want the sum of the
>> tickettabcount and ticketmultabcount, how do I modify my query to get the
>> same. If I use operator "+" in between these, it's been ignored by the
>> PgSQL and throws a error!!
>>
>> QUERY
>> -----
>> select count(tickettab.tokenid) as tickettabcount,
>> (select count(tokenid) from ticketmultab
>> where agentid='danny' and arrivaldate='2001-11-12') as
>> ticketmultabcount
>> from tickettab
>> where tickettab.agentid='danny' and
>> tickettab.arrivaldate='2001-11-12'
>>
>> RESULT
>> -------
>>
>>
>> tickettabcount || ticketmultabcount
>> ------------- ------------------
>> 9 2
>>
HC> Don't use the column name aliasing and it should work:
HC> select sum(tickettab.tokenid) +
HC> (select sum(tokenid) from ticketmultab
HC> where agentid='danny' and arrivaldate='2001-11-12')
HC> from tickettab
HC> where tickettab.agentid='danny' and
HC> tickettab.arrivaldate='2001-11-12' ;
>>
>>
>> Q 2. I join two tables, I get a result set which has values from
>> both the tables, now if I want to sort the combination of the result
>> set how do I do that!!, not the individual table result set.
>>
HC> What is so mysterious about your join?
HC> To answer your question, it would be very helpful to see the query
HC> instead of reading prose.
HC> Reagrds, Christoph
HC> ---------------------------(end of broadcast)---------------------------
HC> TIP 3: if posting/reading through Usenet, please send an appropriate
HC> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
HC> message can get through to the mailing list cleanly
From | Date | Subject | |
---|---|---|---|
Next Message | Mike Rogers | 2001-11-17 04:22:56 | Re: [HACKERS] [PG MAIL LISTS] SEND OUT ALL???? |
Previous Message | Marc G. Fournier | 2001-11-16 19:26:20 | Re: [HACKERS] [PG MAIL LISTS] SEND OUT ALL???? |
From | Date | Subject | |
---|---|---|---|
Next Message | Horst Herb | 2001-11-17 12:18:22 | constraint via selection |
Previous Message | Oleg Lebedev | 2001-11-16 18:44:46 | database tables |