phpmyadmin 将数据库URL拆分为多个域

7bsow1i6  于 2022-11-23  发布在  PHP
关注(0)|答案(1)|浏览(95)

我想把PHPMyAdmin数据库中的2000-3000个链接数据分成5个不同的域,所以我使用了下面的查询,但是这个查询帮助更新了所有的链接。我想把2000个数据分成5个域,我今天该怎么做呢?
我使用查询

UPDATE link SET link =change(link, 'https://test.testr10.com/file/images/','https://test1.testr11.com/file/images/');
js5cn81o

js5cn81o1#

如果知道所有域在更新前都具有相同的test.testr10,则可以使用LIMIT子句进行小批量更新。
假设您有2400条记录...

-- Set the first 500 records
UPDATE link 
   SET link = 'https://test1.testr11.com/file/images/'
 WHERE link = 'https://test.testr10.com/file/images/'
 LIMIT 500;

-- Set the next 500 records
UPDATE link 
   SET link = 'https://test2.testr12.com/file/images/'
 WHERE link = 'https://test.testr10.com/file/images/'
 LIMIT 500;

-- Run again with 3 in the domain
-- Run again with 4 in the domain

-- Even though only 400 records remain, you can still use 500
-- (only the remaining 400 records will match for update)
UPDATE link 
   SET link = 'https://test5.testr15.com/file/images/'
 WHERE link = 'https://test.testr10.com/file/images/'
 LIMIT 500;

根据上面的示例,将在5个查询中覆盖较小集合中的所有2400条记录。将LIMIT值更改为所需的任何值。
下面是一个基于示例的dbfiddle

相关问题