我想搜索包含'Documentversionid'和'ClientMedicationID'列的所有表。
答案 0 :(得分:0)
试试这个:
SELECT t1.TABLE_NAME
FROM
(
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME LIKE '%Documentversionid%'
) t1
INNER JOIN
(
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME LIKE '%ClientMedicationID%'
) t2
ON t1.TABLE_NAME = t2.TABLE_NAME
答案 1 :(得分:0)
这应该这样做:
SELECT COUNT(*) as COUNT, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME
FROM `information_schema`.`columns`
WHERE `TABLE_SCHEMA`='<YOUR DATABASE>' AND
(`COLUMN_NAME` = 'Documentversionid' OR `COLUMN_NAME`='ClientMedicationID')
GROUP BY `TABLE_NAME` HAVING COUNT > 1