查询绑定DAO中的几个表

时间:2018-06-09 10:39:51

标签: php mysql model-view-controller dao

我在为我正在制作的网店写一个查询时遇到了麻烦。

您可以在此处查看我的数据库结构。 Database

enter image description here

我想要一个查询,该查询从我的bvb_orders-design表返回一个用户的订单数组,其大小/金额/价格,并从bvb_design返回image_path。

这是我到目前为止所做的查询

SELECT `bvb_orders`.*, `bvb_users`.`id`, `bvb_designs`.*, `bvb_order-designs`.`size`,`bvb_order-designs`.`amount`, `bvb_designs-paintings`.* FROM `bvb_orders`
  INNER JOIN `bvb_order-designs` ON `bvb_order-designs`.`order_id` = `bvb_orders`.`id`
  INNER JOIN `bvb_designs` ON `bvb_designs`.`id` = `bvb_order-designs`.`design_id`
  INNER JOIN `bvb_users` ON `bvb_users`.`id` = `bvb_orders`.`user_id`
  INNER JOIN `bvb_designs-paintings`ON `bvb_designs-paintings`.`design_id` = `bvb_designs`.`id`
    WHERE `bvb_orders`.`user_id` = :id
    GROUP BY `bvb_orders`.`date`

这是我正在寻找一个给出用户ID订单

的查询的结果
+------------+---------------+--------+------+-------+
|    date    |     title     | amount | Size | price |
+------------+---------------+--------+------+-------+
| 2018-06-07 | Eerste werkje |      1 | M    |    10 |
+------------+---------------+--------+------+-------+

由于

0 个答案:

没有答案