From: | OTR Comm <otrcomm(at)wildapache(dot)net> |
---|---|
To: | PGSQL Novice List <pgsql-novice(at)postgresql(dot)org> |
Subject: | NEWBEE: 'WHERE true' question |
Date: | 2000-11-16 04:16:37 |
Message-ID: | 3A135FA5.C82FD67E@wildapache.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hello,
I have just started learning about PostgreSQL. I am fairly familiar
with MySQL/Perl DBI.
I have some perl code that I downloaded that talks to a pgsql database
and am trying to understand one of the queries in this code.
A snippet from this code is as follows:
...
$where = 'true';
if ($form->{number}) {
$callback .= "&number=$form->{number}";
$where .= " AND number ~* '$form->{number}'";
}
if ($form->{description}) {
$callback .= "&description=$form->{description}";
$where .= " AND description ~* '$form->{description}'";
}
$query = qq|SELECT id, number, description, onhand, unit, sellprice
FROM parts
WHERE $where
ORDER BY $form->{sort}
|;
...
Now if the two 'if' conditionals are false, the query becomes:
SELECT id, number, description, onhand, unit, sellprice
FROM parts
WHERE true
ORDER BY number
What does it mean here for the WHERE to be true? What is being tested
for true? Is this just a 'place holder', if you will, for the WHERE
field in case the two 'if' conditionals are false and so the WHERE field
is not blank?
Thanks,
Murrah Boswell
From | Date | Subject | |
---|---|---|---|
Next Message | GH | 2000-11-16 04:36:58 | Re: NEWBEE: 'WHERE true' question |
Previous Message | GH | 2000-11-15 23:19:48 | Re: Securing table creation |