在几个表中搜索列名,而不是整个数据库SQL

时间:2015-04-01 22:17:35

标签: sql sql-server

SELECT something 
FROM table1, table2, table 
WHERE tableColumn = "tableName"

1 个答案:

答案 0 :(得分:0)

如果有必要,你可以做一些关于模式表的疯狂复杂的事情,但这应该适用于:

select <something> 
    from table1
    where 
        tableColumn = "tableName"
union all
select <something>
    from table2
    where 
        tableColumn = "tableName"
union all
select <something>
    from table3
    where
        tableColumn = "tableName"

只需确保从联合中的每个查询中选择相同类型的列。