jaymc Posted March 6, 2007 Share Posted March 6, 2007 Query UPDATE `members` SET `message` = '1' WHERE ID IN (1,2,3,4,5,6,7,8,9) Question Will adding LIMIT 0,4 mean it will only UPDATE the first 4 ids in that query? Link to comment https://forums.phpfreaks.com/topic/41365-id-in/ Share on other sites More sharing options...
btherl Posted March 6, 2007 Share Posted March 6, 2007 I wouldn't count on it. I can't find any mention in the documentation of such a use of limit with update. Link to comment https://forums.phpfreaks.com/topic/41365-id-in/#findComment-200469 Share on other sites More sharing options...
artacus Posted March 6, 2007 Share Posted March 6, 2007 It WILL update only 4 records. But there is no guarantee that it will be the 4 that you expect. You should get 1 - 4 using an autoinc id. But if you were using something else (last name), it would update the first 4 that it came across and not in A-Z order. You are better off specifying exactly what you want to update instead of relying on LIMIT Link to comment https://forums.phpfreaks.com/topic/41365-id-in/#findComment-200476 Share on other sites More sharing options...
fenway Posted March 7, 2007 Share Posted March 7, 2007 That too... but if you do find that limit works, you'd better use an order by to "guarantee" the same order all the time. Link to comment https://forums.phpfreaks.com/topic/41365-id-in/#findComment-201404 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.