Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无法使用关键字搜索记录,但MySQL中的表中存在该关键字_Php_Mysql - Fatal编程技术网

Php 无法使用关键字搜索记录,但MySQL中的表中存在该关键字

Php 无法使用关键字搜索记录,但MySQL中的表中存在该关键字,php,mysql,Php,Mysql,我有一张结构如下的城市表- # Name Type Collation 1 cityId int(11) 2 countryCode char(5) latin1_swedish_ci 3 cityName varchar(100) utf8mb4_unicode_ci 4 lat varchar(20) latin1_swedish_ci 5 ln

我有一张结构如下的城市表-

#   Name         Type           Collation
1   cityId       int(11)            
2   countryCode  char(5)        latin1_swedish_ci
3   cityName     varchar(100)   utf8mb4_unicode_ci
4   lat          varchar(20)    latin1_swedish_ci
5   lng          varchar(20)    latin1_swedish_ci
我有“countryCode”的城市,比如“ad”-

cityId countryCode cityName   lat        lng
1      ad          Aixàs      42.4833333 1.4666667
2      ad          Aixirivali 42.4666667 1.5
3      ad          Aixirivall 42.4666667 1.5
4      ad          Aixirvall  42.4666667 1.5
5      ad          Aixovall   42.4666667 1.4833333
但当我执行一个查询-
SELECT*FROM city WHERE countryCode='ad'
,我得到的是空数据。我从excel表格中导入了这些数据,该表格有将近3200000条记录。 我已经检查过国家代码前后没有空格。
排序有什么问题吗?我需要做一些转换吗?请提供帮助。

尝试整理您正在搜索的文本,如下所示:

  SELECT * FROM city WHERE countryCode = 'ad' COLLATE latin1_swedish_ci

您可以尝试使用这样的命令:
SELECT*FROM city-WHERE-countryCode-WHERE-WHERE-countryCode-WHERE-WHERE-WHERE-countryCode-WHERE-WHERE-WHERE-WHERE-WHERE-countryCode-WHERE-WHERE-WHERE-WHERE-WHERE-countryCode-WHERE-WHERE-WHERE-countryCode-wh。。。如果返回这些记录,则Excel导入时会出现空白或类似问题。我已经尝试了这两个查询,但结果仍然为空。我注意到,当我手动更新countryCode并进行搜索时,它会返回我更新了countryCode的行。您尝试过选择长度(countryCode)吗其中cityId=xx;(将一条未更新记录的id用作xx,其中countryCode应为'ad')(我假设如果像'%ad%一样不起作用,则a和d之间存在不可见的内容)我的表排序规则为'utf8mb4_unicode_ci',因此它给我的错误为“排序规则'latin1_swedish_ci'对字符集'utf8mb4'无效。”