I have a database of sites for a grounds maintenance company. I want to flag
sites for service. Each site has a service order, 1-875. I want to keep 25
sites flagged for service. Once a technician works on a site and posts a
service report, I set that sites flag to 'no' and would like to flag the
next one in line to 'yes'. I was trying something like this;

Note. I run the query when the technician adds a sites service info.
service_order > 435 is the site the technician just posted their service
info for.

UPDATE site SET service_flag = 'yes' WHERE service_order > '435' AND
service_flag = 'no' and company = 'Nextel' ORDER BY service_order LIMIT 1;

First question, I keep getting errors with the above query. It's having
problems with the ORDER BY and LIMIT. I checked out MySQL website and it
looks like I can order and limit an update. service_order is null, I thought
that was the problem but I tried ORDER BY on a not null field and still had
a problem.

Second question. Is there a way to write in the query that once I've reached
the end, i.e. 875 to start back at 1?

Sorry for the convoluted question. Any help appreciated. 


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to