简体   繁体   English

SQL 使用比较运算符进行查询

[英]SQL Query with comparison operator

SQL Noob and still learning. SQL 菜鸟还在学习。 I am trying to figure out how to write a query that will look up all people hired on or after a date and then query another database and pull out all the paychecks those people received so far.我试图弄清楚如何编写一个查询来查找在某个日期或之后雇用的所有人员,然后查询另一个数据库并提取这些人迄今为止收到的所有薪水。

Example:例子:

SELECT * FROM db2.paychecks 
WHERE paydate >= (SELECT hiredate FROM db1.employees WHERE hiredate >= 2020-01-01)

I know that I cannot use comparison operators with more then one value but I cannot figure out the solution.我知道我不能使用超过一个值的比较运算符,但我无法找出解决方案。

Try this (use your connecting column instead of employeeid):试试这个(使用你的连接列而不是employeeid):

select p.* from db2.paychecks p inner join db1.employees e on p.employeeid=e.employeeid
where e.hiredate>='2020-01-01'

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

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