我收到 MySQL1349
错误,但似乎错误不正确:
ERROR 1349: View's SELECT contains a subquery in the FROM clause
创建视图时可以没有任何子查询吗?
这是我的 SQL:
CREATE VIEW `wordpress`.`ffi_be_v_book_details` AS (
SELECT ffi_be_courses. * , COALESCE( `Total` , 0 ) AS `Total`
FROM `ffi_be_courses`
LEFT JOIN (
SELECT * , COUNT( `Course` ) AS `Total`
FROM ffi_be_courses
RIGHT JOIN (
SELECT `Course`
FROM `ffi_be_bookcourses`
LEFT JOIN `ffi_be_sale` ON ffi_be_bookcourses.SaleID = ffi_be_sale.SaleID
WHERE DATE_ADD( ffi_be_sale.Upload, INTERVAL(
SELECT `BookExpireMonths`
FROM `ffi_be_settings` ) MONTH ) > CURDATE( ) AND ffi_be_sale.Sold = '0'
GROUP BY ffi_be_bookcourses.SaleID
) AS `q1` ON ffi_be_courses.Code = q1.Course
GROUP BY q1.Course
) AS `q2` ON ffi_be_courses.Code = q2.Code
WHERE ffi_be_courses.Type = 'Arts'
ORDER BY ffi_be_courses.Name ASC
)
感谢您的时间。