简体   繁体   English

显示所有mySQL表中的数据

[英]Show data from all mySQL tables

I have a ton of tables that vary in columns by a small amount. 我有一吨的桌子,每列的数量相差很小。 I want to be able to select all the data from every table and just display null values (or blanks) when one table doesn't have a column from another table. 我希望能够从每个表中选择所有数据,并且当一个表没有另一表中的列时仅显示空值(或空白)。

I know this can normally be done using the JOIN operator when you have tables that have relationships between each other, but my tables have no relationships between each other except that they have a lot of common column names. 我知道当您的表之间具有相互关系时,通常可以使用JOIN运算符来完成此操作,但是我的表之间没有关系,只是它们具有许多公共的列名。

无论如何,这是我能想到的最接近的东西: 小提琴

SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.columns
 WHERE TABLE_SCHEMA = 'database_name'
 ORDER BY TABLE_NAME 

This gives you list of all table names. 这将为您提供所有表名的列表。 You can then run queries on all of those. 然后,您可以对所有这些查询运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM