Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
sql选择不使用';t登录_Sql - Fatal编程技术网

sql选择不使用';t登录

sql选择不使用';t登录,sql,Sql,我有一个保存客户输入的url的表。当用户登录时,它会在审核表中保存url“/auth engine/login”。 该表还包含保存登录日期的时间戳 我想查询在特定时间段内未登录的用户。以下是我尝试的内容: select Distinct customer.customer_id ,concat(customer.first_name, ' ', customer.last_name) as name from customer Where customer.customer_id not i

我有一个保存客户输入的url的表。当用户登录时,它会在审核表中保存url“/auth engine/login”。 该表还包含保存登录日期的时间戳

我想查询在特定时间段内未登录的用户。以下是我尝试的内容:

select Distinct customer.customer_id ,concat(customer.first_name, ' ', customer.last_name) as name 
from customer 
Where customer.customer_id not in (
select Distinct customer.customer_id 
from customer
inner join audit on customer.customer_id = audit.username
where audit.url = '/auth-engine/login' And audit.server_response_code in ('200' , '201')
And audit.ts_created Between '2016-01-01' And '2016-12-31' )
然而,这并没有给我预期的结果。 我怎么做


谢谢

您可以将
左连接
一起使用,其中…为空

select *
from customer
left join audit
  on customer.customer_id = audit.username
  and audit.url = '/auth-engine/login' 
  And audit.server_response_code in ('200' , '201')
  And audit.ts_created Between '2016-01-01' And '2016-12-31'

where audit.username is null

您可以将
左连接
一起使用,其中…为空

select *
from customer
left join audit
  on customer.customer_id = audit.username
  and audit.url = '/auth-engine/login' 
  And audit.server_response_code in ('200' , '201')
  And audit.ts_created Between '2016-01-01' And '2016-12-31'

where audit.username is null

您确定customer.customer\u id=audit.username正确吗?您使用的是哪个DBMS?您确定customer.customer\u id=audit.username正确吗?您使用的是哪个DBMS?