Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.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/8/mysql/72.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
Php 列出唯一的行,同时根据给定日期连接两个表_Php_Mysql_Sql - Fatal编程技术网

Php 列出唯一的行,同时根据给定日期连接两个表

Php 列出唯一的行,同时根据给定日期连接两个表,php,mysql,sql,Php,Mysql,Sql,我有两个表,一个包含预订信息,另一个包含集装箱产品信息。下订单时,在预订表中创建一条新记录。我希望得到一个组合表,其中包含基于给定日期的两个表中的所有列 表:预订 ------------------------------------------ | booth_number| booking_date | status | |------------------------------------------| | 1 | 2014-08-15 | b

我有两个表,一个包含预订信息,另一个包含集装箱产品信息。下订单时,在预订表中创建一条新记录。我希望得到一个组合表,其中包含基于给定日期的两个表中的所有列

表:预订

------------------------------------------ | booth_number| booking_date | status | |------------------------------------------| | 1 | 2014-08-15 | booked | | 2 | 2014-09-10 | booked | | 3 | 2014-09-11 | booked | ------------------------------------------ ------------------------------------------ |展位号|预订日期|状态| |------------------------------------------| |1 | 2014-08-15 |预订| |2 | 2014-09-10 |预订| |3 | 2014-09-11 |预订| ------------------------------------------ 表:产品

--------------------------------------------------- | booth_number| desc | locked | type | |------------------------------------------|--------| | 1 | 2 x bottles | true | booth | | 2 | 2 x bottles | | booth | | 3 | 4 x bottles | | booth | | 4 | 4 x bottles | | booth | | 5 | 5 x bottles | | booth | | 6 | 5 x bottles | | booth | | | $20 entry | | ticket | --------------------------------------------------- --------------------------------------------------- |展位号|描述|锁定|类型| |------------------------------------------|--------| |1 | 2个瓶子|真实|展位| |2 | 2个瓶子|展位| |3 | 4个瓶子|展位| |4 | 4个瓶子|展位| |5 | 5个瓶子|展位| |6 | 5个瓶子|展位| || 20美元入场券| --------------------------------------------------- 查询之后,当请求日期为2014-08-15时,我希望得到如下结果

----------------------------------------------------------------------------- | booth_number| desc | locked | type | request_date | status | |------------------------------------------|--------|--------------|----------| | 1 | 2 x bottles | true | booth | 2014-08-15 | booked | | 2 | 2 x bottles | | booth | | | | 3 | 4 x bottles | | booth | | | | 4 | 4 x bottles | | booth | | | | 5 | 5 x bottles | | booth | | | | 6 | 5 x bottles | | booth | | | ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- |展位号|描述|锁定|类型|请求|日期|状态| |------------------------------------------|--------|--------------|----------| |1 | 2瓶|真实|展位| 2014-08-15 |预订| |2 | 2瓶| |展位| |124;| |3 | 4瓶| |展位| |124;| |4 | 4瓶| |展位| |124;| |5 | 5瓶| |展位| |124;| |6 | 5瓶| |展位| |124;| -----------------------------------------------------------------------------
这将列出某一天是否预订的所有展位

请求日期
来自何处?谢谢您的回答。它工作得非常好,理解起来非常清楚。很高兴听到它对你有用。请不要忘记勾选答案,因为这表示结束。
SELECT * FROM products p LEFT OUTER JOIN bookings b ON p.booth_number = b.booth_number where request_date = 'YYYY-MM-DD'
SELECT * FROM products p LEFT OUTER JOIN bookings b ON p.booth_number = b.booth_number where request_date = 'YYYY-MM-DD'