Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/69.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
Mysql 需要组合sql查询的帮助吗_Mysql_Sql_Database - Fatal编程技术网

Mysql 需要组合sql查询的帮助吗

Mysql 需要组合sql查询的帮助吗,mysql,sql,database,Mysql,Sql,Database,我需要一些关于以下问题的帮助 select * from customers where orderdate < 01-09-2010 select * from order where purchasedate < 01-09-2010 我想把上面的查询合并成一个 因此,我希望获得2010年9月1日之后尚未下单的客户。需要两个表中的连接键。 例如,客户的姓名,查询将如下所示 select a.*, b.* from customers a, order b where a.n

我需要一些关于以下问题的帮助

select * from customers where orderdate < 01-09-2010 

select * from order where purchasedate < 01-09-2010
我想把上面的查询合并成一个


因此,我希望获得2010年9月1日之后尚未下单的客户。

需要两个表中的连接键。 例如,客户的姓名,查询将如下所示

select a.*, b.*
from customers a, order b
where a.name = b.customer_name
and a.orderdate < 01-09-2010
and b.purchasedate > 01-09-2010

我认为,如果您发布customer和Order表结构,将两个表中的数据保留在相同的列中,这将是一件好事,因为我怀疑问题需要您需要一个联合
select c.*
from customers c 
left join order o on c.name = o.customer_name and o.purchasedate > 01-09-2010
where c.orderdate < 01-09-2010