On Fri, 2 Jan 2004, Jonathan Villa wrote:
> I have a loop which is similar to the following:
>
> while(array contains elements) {
> UPDATE users SET status = no WHERE name = array[i]
> }
> great, it works but the query runs many times. I want to make only one
> call to the database and have all the elements in the array be included
> in the query
UPDATE users SET status = no WHERE name IN('name1', 'name2', 'name3', ...,
'namen')
you might still have to loop to remake your array to a commaseparated list
of strings, but it will still be boatloads more efficient.
If you have several hundred thousands or more of names and get an error,
try upping your max_allowed_packet variable.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]