Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两张桌子,我们称之为 t1 和 t2。我想选择 t1 中具有特定 ID 的数据,我只能使用 t2 中的 where 子句找到该数据。我不想选择 t2 中的数据(许多具有不同数据的重复列名),那么我该怎么做呢?
尝试这个
select * from t1 where t1.Id in (select distinct Id from t2)
另一种方法是加入表格
SELECT * FROM t1 JOIN t2 on t1.id = t2.id
您正在使用 2 个表之间通用的特定 ID 加入它们。