Address of this article
Share an outline:
1. The background of the matter
2. Workaround
3. Summary
1. The background of the matter
Now the name of 2000 data needs to be queried from the user table, and SQL writes
SELECT * from User WHERE name inch ('name1','name2',... 'name2000');
But out of the query results only 1997, indicating that there are 3 no results, there may be duplicate name, how to query out which 3 data is not the result or duplicate data?
2. Workaround
Guess the use of MySQL should also be found is that the 3 name no results, but for a moment did not think of it, had to use other methods.
The solution is this:
1) "MySQL results export"
First, there is text in the name of the result 1997 that will be queried (MySQL has already sorted the name) Mysql.log
2) "Find duplicate Data"
Then, the original data, using the shell command sort-u processing as Sort_unique.log with the original file Sort.log(also after sort processing) Vimdiff can be seen, Is there a duplicate name, and sure enough there are 1 duplicate name
3) "Find name with no return value"
Finally, Vimdiff, mysql.log and sort_unique.log(both achieve the same sort) can see exactly what name is in the data table The user did not return the
3. Summary
The first is that my MySQL query statement needs to be improved, and then, when a technology does not solve the problem, you can mix multiple technologies.
Like the shell mentioned above in the text processing, sorting, de-weight, contrast shows the advantages of unparalleled, much faster than the language processing such as PHP.
--In addition:
Have to know how to query directly with the SQL statement which name has no results of the classmate, also welcome the reply ha, learn to communicate together to improve, thank you ~
"Daily Development" uses a variety of tools to implement SQL queries with no results for name