Mysql SQL statements are too long and cause problems. I am doing data statistics now. MYSQL is used in the background database. There is a common requirement to query the PV of unordered users (the user's unique ID is the user's mobile phone number); the first statement is: select count (1) FROM nation WHERE mobile_number not in (select distinct mobile_number FROM tbl_cartoon_order); Method 2: Use select distinct mobile_number FROM tbl_cartoon_order to obtain a List <String> combination, concatenate the collection of the obtained mobile phone numbers into a string. When select count (1) FROM day_resinlog_2012_06_12 WHERE mobile_number not in (xxxxx) IN xxxxx, comment: the first method uses subquery, this process is slow. We don't need it because we chose the second method. There is no problem with the second method on the surface, but there is also a potential risk. If we order millions of mobile phone numbers, the server may report an error. If an SQL statement is too long and exceeds the max_allowed_packet value in the MYSQL server configuration file (my. ini in windows), an error is returned. The solution is to change the max_allowed_packet volume. Author: lovemelovemycode