Re: [PHP-DB] Re: LEFT JOIN in UPDATE

2002-02-04 Thread Lutz Brückner

[EMAIL PROTECTED] (Adv. Systems Design) writes:

 I was simply going by the docs themselves:
 http://www.mysql.com/doc/A/N/ANSI_diff_Sub-selects.html
 (see bottom of page)

yes, using REPLACE may be a solution. But you have to make a copy of 
the original table, because REPLACE cannot access the values of the
old row directly.

I'd prefer to do this in the mysql way  - on the php side.


 Now before you get your flamethrower out...yes I AM
 KIDDING...I realize that mysql is maturing and all
 these features will EVENTUALLY make it in...

Some compromises are necessary when using mysql, but often the
advantages prevailing.

Lutz

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Re: LEFT JOIN in UPDATE

2002-02-03 Thread Lutz Brückner


[EMAIL PROTECTED] (Adv. Systems Design) writes:

 Question is how to properly form a LEFT JOIN using
 UPDATE... I tried:
 
 UPDATE product_price LEFT JOIN temp 
 SET product_price.product_price_vdate = 1 (del flag)
 ON product_price.product_id = temp.product_id
 WHERE temp.product_id IS NOT NULL

I just read http://www.mysql.com/doc/U/P/UPDATE.html once more,
but can not find anything about mysql supporting JOIN in UPDATE
statements.

Sorry,
 Lutz

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Re: LEFT JOIN in UPDATE

2002-02-03 Thread Paul Burney

on 2/3/02 3:36 PM, Lutz Brückner at [EMAIL PROTECTED] appended the following
bits to my mbox:

 Question is how to properly form a LEFT JOIN using
 UPDATE... I tried:
 
 UPDATE product_price LEFT JOIN temp
 SET product_price.product_price_vdate = 1 (del flag)
 ON product_price.product_id = temp.product_id
 WHERE temp.product_id IS NOT NULL

 I just read http://www.mysql.com/doc/U/P/UPDATE.html once more,
 but can not find anything about mysql supporting JOIN in UPDATE
 statements.

I believe Lutz is right.  You are using PHP, right?  Any MySQL?

Some RDBMS systems provide ways of linking database table records to each
other via foreign keys and others allow you to create triggers that are
performed by the database server when certain actions happen.

MySQL does not.  They believe the application programmer should take care of
those application pieces.

So, if you're using MySQL, do the select statement first with the join, then
loop through the results and perform the update.

Paul

?php
while ($self != asleep) {
$sheep_count++;
}
?



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php