数据库:如何从具有一个公共列的两个表中获取多个值

Database: how to get multiple values from two tables having one common column

我有两个 tables:

Table#1:列

Producer   ConsumerKey    time                resourcepath    Day
------------------------------------------------------------------
test           7890       2018-09-25 09:44     /12345         23
dev            5678       2018-09-25 09:10     /abcv          26

Table #2:列

ConsumerName    ConsumerKey    Day
-----------------------------------
admin              7890        23
dummy              5678        26

我需要以这样的方式查询 tables,以便我应该从 table 1 中获取不同的值,并从 table 2 中获取特定日期的相应消费者名称

所以最终结果应该是这样的:

Producer    ConsumerKey   time                resourcepath   ConsumerName   Day
-------------------------------------------------------------------------------
test            7890      2018-09-25 09:44    /12345         admin          23
dev             5678      2018-09-25 09:10    /abcv          dummy          26

有什么办法可以得到这个。请帮忙

谢谢

基本连接应该可以工作。

SELECT t1.producer,
       t1.consumerkey,
       t1.time,
       t1.resourcepath,
       t2.consumername,
       t1.day
       FROM table1 t1
            INNER JOIN table2 t2
                       ON t2.consumerkey = t1.consumerkey
                          AND t2.day = t1.day;
SELECT DISTINCT table1.Producer, table1.ConsumerKey, table1.Time, table1.resourcepath, table1.day, table2.ConsumerName 
FROM table1, table2 
WHERE table1.ConsumerKey = table2.ConsumerKey 
AND table1.time = "<ENTER YOUR TIME HERE>"

这可以很好地获取以下详细信息。