我有两个可用的sql语句:
select firstName from table1 s INNER JOIN table2 t ON s.LoginId = t.userId
和
select testScore from table2 where userId in (select loginId from table1)
如何组合这些陈述
firstName
第一个语句的被添加到第二个语句的输出中(即输出产生firstName和testScore?
答案 0 :(得分:1)
您只需要JOIN
两个表格。你已经这样做了,所以也许你的问题中缺少一些信息或要求,为什么以下不起作用?
SELECT s.firstName, t.testScore
FROM table1 s
INNER JOIN table2 t ON (s.LoginId = t.userId)