我最初在这个线程中发布了一个问题:
mysql - 显示所有表中存在的值
幸运的是,aleroot 提出了一个解决方案。我试过了,一切似乎都奏效了。但是,我添加了更多表格,但由于某种原因它不再起作用。
作为测试,我在所有 29 个表中导入了相同的值。但是,当我运行下面的查询时,它不会返回任何行。不知道我做错了什么。任何帮助将不胜感激。谢谢
SELECT @rownum:=0;
SELECT name FROM userinformation ui WHERE EXISTS (
SELECT user_id FROM userinformation t1
INNER JOIN table1 USING(user_id)
INNER JOIN table2 USING(user_id)
INNER JOIN table3 USING(user_id)
INNER JOIN table4 USING(user_id)
INNER JOIN table5 USING(user_id)
INNER JOIN table6 USING(user_id)
INNER JOIN table7 USING(user_id)
INNER JOIN table8 USING(user_id)
INNER JOIN table9 USING(user_id)
INNER JOIN table10 USING(user_id)
INNER JOIN table11 USING(user_id)
INNER JOIN table12 USING(user_id)
INNER JOIN table13 USING(user_id)
INNER JOIN table14 USING(user_id)
INNER JOIN table15 USING(user_id)
INNER JOIN table16 USING(user_id)
INNER JOIN table17 USING(user_id)
INNER JOIN table18 USING(user_id)
INNER JOIN table19 USING(user_id)
INNER JOIN table20 USING(user_id)
INNER JOIN table21 USING(user_id)
INNER JOIN table22 USING(user_id)
INNER JOIN table23 USING(user_id)
INNER JOIN table24 USING(user_id)
INNER JOIN table25 USING(user_id)
INNER JOIN table26 USING(user_id)
INNER JOIN table27 USING(user_id)
INNER JOIN table28 USING(user_id)
INNER JOIN table29 USING(user_id)
WHERE t1.user_id = ui.user_id
);