Mysql 添加and语句时出错,应在何处插入and语句

Mysql 添加and语句时出错,应在何处插入and语句,mysql,sql,database,Mysql,Sql,Database,我正在尝试从客户下单的位置提取查询,该查询在2008年10月27日之后,子查询中的和将是where: SELECT * from customer WHERE customer.cust_id in (SELECT orders.cust_id from orders and orders.order_date > '2008-10-27') 我建议改为存在;它可以更好地适应大型数据集。此外,表别名可以方便地缩短查询并使其更具可读性: select * from customer

我正在尝试从客户下单的位置提取查询,该查询在2008年10月27日之后,子查询中的
将是
where

SELECT * from customer WHERE customer.cust_id in (SELECT orders.cust_id from orders and orders.order_date > '2008-10-27') 
我建议改为
存在
;它可以更好地适应大型数据集。此外,表别名可以方便地缩短查询并使其更具可读性:

select * 
from customer 
where customer.cust_id in (
    select orders.cust_id from orders where orders.order_date > '2008-10-27'    
)

哇,谢谢!我还没来得及修改格式!
select c.*
from customer c
where exists (
    select 1 
    from orders o
    where o.cust_id = c.cust_id and o.order_date >  '2008-10-27'
)