@
alsotang 你没跑过你的SQL吧,会报错的,亲。给你修改一下改成
select a1.aid from a as a1 inner join a as a2 where a1.bid = 47 and a1.bid = 22 and a1.aid = a2.aid;
这下不报错了,结果返回 Empty set (0.00 sec)
用我的sql实验,返回的是
+------+
| aid |
+------+
| 100 |
+------+
1 row in set (0.00 sec)
我建的测试数据库数据和LZ给出的一致。
explain分析一下你的语句就知道错误在那里了
mysql> EXPLAIN
-> select a1.aid from table_a as a1 inner join table_a as a2 where a1.bid = 47 and a1.bid = 22 and a1.aid = a2.aid;
+----+-------------+-------+------+---------------+------+---------+------+------+------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+------------------+
| 1 | SIMPLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Impossible WHERE |
+----+-------------+-------+------+---------------+------+---------+------+------+------------------+
Impossible WHERE