You are here: Re: UPDATE multiple fields in one statement « PHP SQL « IT news, forums, messages
Re: UPDATE multiple fields in one statement

Posted by J.O. Aho on 09/30/39 11:29

charliefortune wrote:
> That's it, thank you. My price field is a float, and tracking_url is
> varchar. Is this why one works without quotes and the other needs them
> ?

Yes, varchar requires quotes or else it won't know what is part of the varchar
or what is the rest of the query.


> Also, is it more efficient to do several updates in a single query, I
> would assume so ?

It depends on how your query looks like, if you use just one statement when
you update, then it don't matter how much you update, but the exception is
when you feed the sql server with many statements at the same time, eg:


$query = "UPDATE product SET price=$newprice1, tracking_url='$newtracker1'
WHERE ASIN=$product_asin1; UPDATE product SET price=$newprice2,
tracking_url='$newtracker2' WHERE ASIN = $product_asin2";


This will make it really difficult to know what did cause a fault if you get
an error message. The slight speedup you get from the multi statement query is
to small to overweight the impossibility to track the errors, that it's a lot
better to make multiple queries which you can easily error check and handle.
The only time to make those multi statement queries would be if the sql server
runs on another machine and the connection is really bad between them (a lot
of package losses), but in that scenario, it would be a lot better to find
another server to have the sql on.



//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация