我有两张桌子:
t1:
cust_id email
201 email1@sadpanda.com
202 email2@email.com
203 email3@sadpanda.com
t2:
cust_id value
201 dfceaa64f8b93661903a849b09c5ac4e10abdfed21763a04d6eb9523e02d6dc1:Qs
202 c15af11e5acb2f6b7e7b12ab7eee8ce482f0cf76f76b7e65dde6b15c3a910680:Qx
203 71ae98d020b16f6f668db6bde3f9c18350a892b55736995237fa71aa5dc2b206:MU
我想从't1'中选择电子邮件就像'sadpanda',并从't2'接收这些用户的值。我应该使用内部联接吗?
答案 0 :(得分:0)
SELECT t2.*
FROM t2
JOIN t1 USING (cust_id)
WHERE t1.email = 'email3@sadpanda.com'
答案 1 :(得分:0)
你可能有两种方法可以做到这一点 1.您可以使用简单的连接查询。
之类的东西SELECT T2.*
FROM T1 JOIN T2 ON T.CUST_ID = T2.CUST_ID
WHERE T1.EMAIL LIKE '%sadpanda%'
或者您可以使用类似
的子查询选择T2。* 来自T2 在哪里CUST_ID(从T1中选择CUST_ID T1.EMAIL喜欢'%sadpanda%')
我建议先做一个。它将比第二个运行得更快。