Php looping like query and modification methods in batches
Source: Internet
Author: User
The following describes how to query and modify the like statements in a php loop. Two tables are available: dataA label table idkeytagid1 keyword 2 tagid (ID corresponding to the keyword )...... The title content of idnametagid1 in the dataB information table is marked as a method for querying and modifying like statements in php loop.
There are two tables
DataA label table
Id key tagid
1 keyword 2 tagid (ID corresponding to the keyword)
......
DataB info table
Id name tagid
1. the title content tag corresponds to the tagid
Nearly 2 K data entries in the dataA table
About Data in the dataB table
I want to match the key of Table A with the name of Table B. If so, I will assign the tagid to the id of Table B.
I wrote it like this.
$ SQL = ...... Query Table
Foreach ($ sqlRs as $ tkey) {// loop the key of Table
$ Bsql = "select id from dataB where name like '%". $ tkey ['key %']. "% '";
......
Foreach (){
Cyclic output id
$ SArray [] = $ bRs ['id'];
}
Update () // modify the name of related B;
}
This method is similar, but now I have so much data, it takes several minutes for A to be several thousand. Please help me think about any better way.
------ Solution --------------------
Google "tag database" will find several articles.
------ Solution --------------------
LZ loop query update is definitely not available. 2 K and 10 W will be exhausted.
Check the usage of case when. You can try it.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service