From: | greg(at)turnstep(dot)com |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Cc: | m_tessier(at)sympatico(dot)ca |
Subject: | Re: selecting the record before the last one |
Date: | 2003-06-26 14:57:27 |
Message-ID: | 7a453c6139cf0bac3d55f4bae007177d@biglumber.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
The quick answer is no: you cannot specifically match a certain column
and not match a certain column at the same time.
You are already creating the SQL statements manually, so why not just create
different ones for each situation?
if (historical search) {
$query = "SELECT * FROM difference WHERE clientid = $CLIENTID ORDER BY cartid ASC LIMIT 1";
}
else {
$query = "SELECT * FROM difference WHERE clientid = $CLIENTID AND cartid = $CARTID";
}
More importantly, however, there seems to be a fatal flaw in your process:
> By adding the "ORDER BY cartid ASC LIMIT 1" to the sql statement, the user
> gets the most recent credit amount for that customer entered into the
> system. That is, the credit amount created by the previous invoice.
> ...when the user is creating an invoice, that invoice's cartid (which is
> a random number) is already entered into the system,
If "cartid" is a random number, 'ORDER BY cartid ASC' is not going to do you any good.
- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200306261048
-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html
iD8DBQE++wlmvJuQZxSWSsgRAizgAJ9tXUD9i3fhbhPQMw7V9z7AXbSwuQCgkfHg
hsq/uuge0mxcyoj9WqAYkTY=
=0WLM
-----END PGP SIGNATURE-----
From | Date | Subject | |
---|---|---|---|
Next Message | Manfred Koizar | 2003-06-26 14:59:55 | Re: full featured alter table? |
Previous Message | Tom Lane | 2003-06-26 14:52:02 | Re: [GENERAL] Physical Database Configuration |