[thelist] is this correct PHP/SQL or a better way?
rudy
r937 at interlog.com
Tue Jan 7 15:33:01 CST 2003
> At the end of a process, I have to run through this dynamic table I
> built, and use the values within to update another existing table.
dynamic table?
> Question 1) Is this a good way with PHP to loop through my result set
> (I need to hit every row) or there a better way with some kind of FOR
> loop?
calling the database inside a loop is inefficient, but in mysql, you don't
have the luxury of updating one table from another
> Question 2) In my SQL, I need what I *think* is called an aggregate
> value(?). I need to take the $qty value and ADD it to the bought
> value that already exists for that row. I don't think my SQL is
> correct there though...
your UPDATE syntax is fine
for another approach, consider creating the final values you need by doing a
temp table join, then delete/insert or replace those rows in your registry
table
see last user comment on this page --
http://www.mysql.com/doc/en/UPDATE.html
since you are using a dynamic table(?), this may work for you
rudy
More information about the thelist
mailing list