1

I am trying to use limit with update in mysql but is giving an error

Error: MySQL Error: Incorrect usage of UPDATE and LIMIT

update table1
JOIN table2 
  ON SUBSTRING_INDEX(table1.HOST, '.',1)= SUBSTRING_INDEX(table2.HOST, '.', 1)
set table1.portalId = table2.portalId
limit 2;
meallhour
  • 13,921
  • 21
  • 60
  • 117
  • Well, the documentation clearly states that "For multiple-table syntax, ORDER BY and LIMIT cannot be used." (https://dev.mysql.com/doc/refman/8.0/en/update.html) – Mureinik Jun 28 '18 at 20:38

2 Answers2

0

However, you cannot use ORDER BY or LIMIT with a multiple-table UPDATE.

From the official reference

It's also the exact text shown when you search google for "mysql update limit".

Uueerdo
  • 15,723
  • 1
  • 16
  • 21
0

LIMIT can be used with UPDATE but with the row count only. You can try doing an inner select which may be more complicated but you may just be able to use your desired limit in there

MYSQL Reference

BlackMarker
  • 139
  • 12