> Table structures:
>
> ce_house
>
> house_id
> provider_id
>
> ce_contract
>
> contract_id
> house_id
> contract_term
> contract_created
>
> ce_contract_status
>
> contract_status_id
> contract_id
> contract_status
> contract_status
My current solution to the problem is PHP and it - simply put - sucks
I loop through all the house records for a user using the following query
SELECT * FROM ce_house
LEFT JOIN ce_contract ON ce_house.house_id=ce_contract.house_id LEFT JOIN ce_contract_status
On Jun 7, 2006, at 8:53 , Kenneth B Hill wrote:
Make a "view" with a
query, then perform a query using the view, etc. , then drop all views
in the SQL script. This may make the entire operation perform faster.
I don't know how using a view would improve performance. However, it
may make the
That looks like a very complex query. I would like to suggest that you
try doing some nesting queries via a SQL script. Make a "view" with a
query, then perform a query using the view, etc. , then drop all views
in the SQL script. This may make the entire operation perform faster.
-Ken
On Tue, 20
> Hi,
>
> I have one to many (from left to right)
> relationships among the below tables
> in my database
>
> user -> house -> contract -> contract status
>|
>
> Also, a single house has a single provider and the
> provider has multiple
> rates inside the provider_rate table in
>
On Tue, Jun 06, 2006 at 11:10:46AM -0700, Burak Seydioglu wrote:
> I have a query to return the latest contract and contract status for a
> house... What i am trying to do is to get the rate of electricity for the
> latest contract... I am trying to retrieve the latest provider rate before a
> cont
Hi,I have one to many (from left to right) relationships among the below tables in my databaseuser -> house -> contract -> contract status |Also, a single house has a single provider and the provider has multiple
rates inside the provider_rate table in chronological order.I have a que
Hi,
I have a problem with this join query:
SELECT
CASE WHEN (UR.id_rights IS NULL) THEN '0' ELSE UR.id_rights END as
id_rights,
CASE WHEN (UR.r_category IS NULL) THEN 'CMP' ELSE UR.r_category END as
category,
U.id as id_user,
U.username
FROM mgw_users U LEFT OUTER JOIN mgw_cnt_us
On Wed, 15 Dec 2004, Marian POPESCU wrote:
> Hi,
>
> I have a problem with this join query:
>
>
> SELECT
> CASE WHEN (UR.id_rights IS NULL) THEN '0' ELSE UR.id_rights END as
> id_rights,
> CASE WHEN (UR.r_category IS NULL) THEN 'CMP' ELSE UR.r_category END as
> category,
> U.id
Hi,
I have a problem with this join query:
SELECT
CASE WHEN (UR.id_rights IS NULL) THEN '0' ELSE UR.id_rights END as
id_rights,
CASE WHEN (UR.r_category IS NULL) THEN 'CMP' ELSE UR.r_category END as
category,
U.id as id_user,
U.username
FROM mgw_users U LEFT OUTER J
On Wed, Apr 21, 2004 at 02:29:34PM -0400, Heflin wrote:
> OK, it's been a while since I've had to do anything remotely complex in
> SQL, so this may just be a pure brain block on my part.
>
...
>
> So a basic JOIN gets this:
>
> SELECT auction.auction_id, image.image_id, image.image_descr
> FROM
On Wed, Apr 21, 2004 at 14:29:34 -0400,
Heflin wrote:
>
> SELECT auction.auction_id, image.image_id, image.image_descr FROM
> auction JOIN image ON auction.auction_id = image.auction_id WHERE
> auction.auction_owner = 'Mabel';
>
In my opinion there are 2 problem: how can you make the query
Heflin <[EMAIL PROTECTED]> writes:
> Bruno Wolff III wrote:
>> The postgres specific way of doing this is:
>> SELECT DISTINCT ON (auction.auction_id)
>> auction.auction_id, image.image_id, image.image_descr
>> FROM auction JOIN image ON auction.auction_id = image.auction_id
>> WHERE auction.auction
On Wed, Apr 21, 2004 at 16:28:10 -0400,
Heflin <[EMAIL PROTECTED]> wrote:
> >
> >The postgres specific way of doing this is:
> >SELECT DISTINCT ON (auction.auction_id)
> > auction.auction_id, image.image_id, image.image_descr
> > FROM auction JOIN image ON auction.auction_id = image.auction_id
Two choices that work:
Either add another JOIN in which retrieves the MAX(image_id) for each
auction:
SELECT auction.auction_id, image.image_id, image.image_descr
FROM auction
JOIN image USING(auction_id)
JOIN ( SELECT auction_id, MAX(image_id) AS image_id
FROM image
On Wed, Apr 21, 2004 at 14:29:34 -0400,
Heflin <[EMAIL PROTECTED]> wrote:
>
> So a basic JOIN gets this:
>
> SELECT auction.auction_id, image.image_id, image.image_descr
> FROM auction JOIN image ON auction.auction_id = image.auction_id
> WHERE auction.auction_owner = 'Mabel';
>
> Now the prob
Bruno Wolff III wrote:
On Wed, Apr 21, 2004 at 14:29:34 -0400,
Heflin <[EMAIL PROTECTED]> wrote:
So a basic JOIN gets this:
SELECT auction.auction_id, image.image_id, image.image_descr
FROM auction JOIN image ON auction.auction_id = image.auction_id
WHERE auction.auction_owner = 'Mabel';
Now
OK, it's been a while since I've had to do anything remotely complex in
SQL, so this may just be a pure brain block on my part.
I have 2 tables, auction and image, defined like this:
Table "public.auction"
Column | Type |
18 matches
Mail list logo