【求大神】现在有1000个string与一个MYSQL字典,查询这1000个string在MYSQL中的id并输出结果
黄舟
黄舟 2017-04-17 15:24:41
0
2
813

1.这是需要查询string的示例(txt文件)
vivo X5S L
CHE-TL00H
G621-TL00
vivo Y51A
KIW-AL10
Samsung SM-G9200
XiaoMi MI PAD
Samsung SM-G9008V
XiaoMi MI 4C
MX4 Pro
R7007
ALE-TL00
iPad3_4
XiaoMi HM NOTE 1TD
HUAWEI P7-L09
iPhone8_4

2.在Mysql中有这样的一张表(示例)
mid bid sid type productname
p1 mobile81 s000 mobile 多普达S900(Touch Diamond)
p2 mobile81 s000 mobile 多普达T8388(麒麟)
p3 mobile81 s000 mobile 多普达T8588
p4 mobile81 s265 mobile 多普达S1(触动版)
p5 mobile81 s000 mobile 多普达696
p6 mobile81 s000 mobile 多普达838
p7 mobile81 s000 mobile 多普达T2222(Touch Viva)
p8 mobile81 s265 mobile 多普达S1
p9 mobile81 s000 mobile 多普达T5399
p10 mobile81 s267 mobile 多普达A6188
p11 mobile81 s264 mobile 多普达D600(活力版)
p12 mobile81 s000 mobile 多普达P800
p13 mobile81 s000 mobile 多普达C720
p14 mobile81 s264 mobile 多普达D600

3.
需要查询1中在2中的结果并返回mid

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(2)
伊谢尔伦
$prodArr = explode("\n",file_get_content('prods.txt')); // 获取txt中的文本并依据换行符将字符串转成数组
$prods = implode(',',$prodArr); // 将产品数组转成where条件
$sql = 'SELECT mid FROM prods WHERE "productname" IN('.$prods.')'; // 组合查询Mid的sql

Firstly, I have implemented one according to the idea of ​​the topic owner, which should be what the topic owner wants.

If you find any mistakes, please try your best to hit them

Ty80

You are missing a layer of key-value pair relationships. The English in the txt file corresponds to the productname and its product_code in the data table. This kind of query is too tiring. You might as well use stored procedures or functions or code tools to handle it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!