我发现MySQL查询存在一个奇怪的问题 我有这张桌子
+--------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+------------------+------+-----+---------+-------+
| aid | varchar(50) | NO | PRI | NULL | |
| sid | int(10) unsigned | NO | PRI | NULL | |
| cid | int(10) unsigned | NO | PRI | NULL | |
| signature | int(10) unsigned | NO | | NULL | |
| sig_name | varchar(255) | YES | | NULL | |
| sig_class_id | int(10) unsigned | YES | | NULL | |
| sig_priority | int(10) unsigned | YES | | NULL | |
| timestamp | datetime | NO | | NULL | |
| ip_src | int(10) unsigned | YES | | NULL | |
| ip_dst | int(10) unsigned | YES | | NULL | |
| ip_proto | int(11) | YES | | NULL | |
| layer4_sport | int(10) unsigned | YES | | NULL | |
| layer4_dport | int(10) unsigned | YES | | NULL | |
| isp | varchar(16) | YES | | NULL | |
| ispdst | varchar(16) | YES | | NULL | |
+--------------+------------------+------+-----+---------+-------+
当我执行
时 SELECT DISTINCT timestamp
, aid
, sig_name
, inet_ntoa(ip_src)
, inet_ntoa(ip_dst)
FROM acid_event
WHERE ip_src !=0
AND ip_dst !=0
AND 1=1
AND aid = '10.10.10.94'
AND ip_src = '3305661330'
GROUP BY aid
, ip_src
, ip_dst
, timestamp
, sig_name
, isp
ORDER BY timestamp DESC
LIMIT 0,25;
MySQL返回结果,一切正常但是当我将查询更改为
时SELECT DISTINCT timestamp
, aid
, sig_name
, inet_ntoa(ip_src)
, inet_ntoa(ip_dst)
FROM acid_event
WHERE ip_src !=0
AND ip_dst !=0
AND 1=1
AND ip_src = '3305661330'
GROUP BY aid
, ip_src
, ip_dst
, timestamp
, sig_name
, isp
ORDER BY timestamp DESC
LIMIT 0,25;
MySQL重新调整空集
答案 0 :(得分:1)
在两个查询中,您都将整数与varchar:
进行比较ip_src = '3305661330'
但ip_src实际上是一个整数(10)无符号。所以试试这个:
ip_src = 3305661330