The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Is there a way to set data in multiple records in one query?
In MySQL, is there an efficient way to set a field to a specified list of values in a corresponding list of where conditions (based on the primary key), or do I have to do an individual UPDATE query for each record?
|
#2
|
||||
|
||||
Sorry you've totally lost me. Can you perhaps give an example of what you're trying to do ?
|
#3
|
||||
|
||||
you could write a function to do that, but you'd still end up with more queries.
$list[0] = "..."; $list[0] = "..."; $where[0] = "..."; $where[1] = "..."; for($i = 0; $i < sizeof($list); $i++) { mysql_query("UPDATE table SET $list[$i] WHERE $where[$i]"); } |
#4
|
||||
|
||||
Quote:
|
#5
|
|||
|
|||
With this loop you ARE sending multiple queries.
Better to do like Dean asked and give an examplke of what you try to do. |
#6
|
||||
|
||||
Quote:
Quote:
|
#7
|
||||
|
||||
Quote:
Also, people are always talking about the cost of a hack in terms of queries, but I can easily construct a query that will take 10 times longer to execute than another. What gives? I hardly believe that the majority of users concerned with such things aren't using mysql as a library, so I don't understand why the number of queries should be more important than the time spent executing them. |
#8
|
||||
|
||||
Hmmm, well by the sounds of things what you're doing doesn't sound very efficient either way. As I said before why not tell us exactly what you're trying to do then we can give tips. It's hard to offer advice without an example
|
#9
|
||||
|
||||
Quote:
Quote:
|
#10
|
|||
|
|||
Quote:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|