繁体   English   中英

在 postgres/redshift 的多个表中使用 SELECT *

[英]Using SELECT * from multiple tables in postgres/redshift

我有 3 个表,所有表都有 2 个公共字段(id, timestamp) 我想做这样的事情:

SELECT * 
FROM table1, 
     table2, 
     table3 
WHERE id = '123' 
      and timestamp = '1704'

我期望的是它返回 3 个表中 id 和时间戳匹配的所有行。 如何修改查询以实现此目的?

 select /*your_columns*/
   from table1 
   inner join table2 on table1.id = table2.id and table1.timestamp = table2.timestamp
   inner join table3 on table2.id = table3.id and table2.timestamp = table3.timestamp
 where table1.id = '123'and table1.timestamp = '1704'

在此处查看有关 JOIN的更多信息

暂无
暂无

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

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