我有这张table
+----+------------+------------+------------+-------+------+----------+------------+------------+------------+
| id | base_price | startDate | endDate | cost | type | Duration | product_id | created_at | updated_at |
+----+------------+------------+------------+-------+------+----------+------------+------------+------------+
| 1 | 100.00 | 1537390800 | 1538773200 | 95.00 | day | 2 | 9 | NULL | NULL |
| 2 | 100.00 | 1537390800 | 1538773200 | 85.00 | day | 3 | 9 | NULL | NULL |
| 3 | 100.00 | 1537390800 | 1538773200 | 75.00 | day | 4 | 9 | NULL | NULL |
| 4 | 100.00 | 1537390800 | 1538773200 | 70.00 | day | 5 | 9 | NULL | NULL |
+----+------------+------------+------------+-------+------+----------+------------+------------+------------+
和产品表
+----+----------------------------+-----------+-----+-------+---------+--------------+---------------------+---------------------+---------------------+
| id | alias | status | img | price | user_id | published_at | deleted_at | created_at
| updated_at |
+----+----------------------------+-----------+-----+-------+---------+--------------+---------------------+---------------------+---------------------+
| 8 | toyota-corolla-1-6-elegant | draft | 18 | 30 | 1 | 2018-08-14 | NULL | 2018-08-14 15:06:12 | 2018-08-20 14:58:18 |
| 9 | test | published | | 0 | 1 | 2018-08-23 | 2018-09-10 19:44:29 | 2018-08-23 14:45:18 | 2018-09-10 19:44:29 |
+----+----------------------------+-----------+-----+-------+-------
现在我试试这个sql
SELECT *
FROM products,
(SELECT *
FROM season
WHERE Duration = ( SELECT MAX(Duration) FROM ec_season WHERE `Duration` <= 3)
) as t1
LEFT OUTER JOIN t1
ON t1.product_id = products.id
但它给了我
1146-表'**.t1'不存在
如何将产品连接到t1?
1条答案
按热度按时间2lpgd9681#
试试这个:你的连接语法不正确