|
Home > Archive > PostgreSQL Discussion > August 2005 > A strange problem
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Tang Tim Hei 2005-08-27, 11:23 am |
| Hi,
I'm new to postgresql. Anytime I type the following command to the database to run, it give me no result record if table 'country' is empty but can get result if 'country' is not empty. Is this so strange?
select A.* from test.currency A, test.country B where A.curr_cd='USD'
---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster
| |
| Stephan Szabo 2005-08-27, 11:23 am |
| On Sat, 27 Aug 2005, Tang Tim Hei wrote:
> Hi,
> I'm new to postgresql. Anytime I type the following command to the
> database to run, it give me no result record if table 'country' is
> empty but can get result if 'country' is not empty. Is this so
> strange?
Not really. You're doing a cartesian join between test.currency and
test.country. If there are no rows in test.country, there are no rows in
the output of the from clause.
> select A.* from test.currency A, test.country B where A.curr_cd='USD'
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend
| |
| Douglas McNaught 2005-08-27, 11:23 am |
| Tang Tim Hei <timheit@netvigator.com> writes:
> Hi,
> I'm new to postgresql. Anytime I type the following command to the database to run, it give me no result record if table 'country' is empty but can get result if 'country' is not empty. Is this so strange?
>
> select A.* from test.currency A, test.country B where A.curr_cd='USD'
You're doing an unconstrained join on "currency" and "country", and if
one of those two tables is empty the result will be empty.
-Doug
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend
|
|
|
|
|