简体   繁体   English

找不到MYSQL记录

[英]MYSQL Records not found

I have imported a CSV into MYSQL. 我已将CSV导入MYSQL。 It all worked fine and i can see the records fine through PHPMYADMIN and through the console. 一切正常,我可以通过PHPMYADMIN和控制台查看记录。 But when i search for a record that i know is there, it isnt finding it. 但是,当我搜索我知道的记录时,并没有找到它。

Query is basically - 查询基本上是-

SELECT * from `companies` where `name` = 'test'; <--- I corrected this because all the answers are talking about the query. The problem isnt with the query. Please read my update following. 

But once i manually edit that column and save, the same query finds it fine. 但是,一旦我手动编辑该列并保存,相同的查询就会发现它很好。

I have tried to TRIM the column but it isnt making any difference. 我试图对TRIM列进行修剪,但没有任何区别。

Please help. 请帮忙。 Thank you in advance. 先感谢您。

UPDATE: The issue isn't with the query. 更新:问题不在于查询。 The query works fine once I manually edit the record and save it. 我手动编辑记录并保存后,查询工作正常。 So i think it has to do with returns or non-ASCII characters in the record itself or a collation issue. 因此,我认为这与记录本身的返回或非ASCII字符或排序规则有关。

This will find word 'test' in your name column so extra spaces will not effect your result but this is wild searching so it will match also words like 'testing', 'this is test' etc so if you want exactly match with particular word like 'test' you can't use this but you can check result with this query. 这将在您的name栏中找到单词“ test”,因此多余的空格不会影响您的结果,但这是疯狂的搜索,因此它也将与“ testing”,“ this is test”等单词匹配,因此如果您想与特定单词完全匹配像“测试”一样,您不能使用它,但是可以通过此查询检查结果。 If you getting your result using this query it means there are extra spaces in your column value. 如果使用此查询得到结果,则意味着列值中有多余的空格。

SELECT * from companies where name LIKE %test%;

删除BackTicks以进行价值测试

SELECT * from companies where name = "test";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM