I need to modify MySQL code to pass this error and get the same result.
I use localhost with Xampp ..
- Apache/2.4.29 (Win32) OpenSSL/1.1.0g PHP/7.2.1
- Server type: MariaDB
- Server version: 10.1.30-MariaDB – mariadb.org binary distribution
- Database client version: libmysql – mysqlnd 5.0.12-dev – 20150407
- PhpMyAdmin Version information: 4.7.4, latest stable version: 4.9.1
CREATE VIEW product_variation_stock_view AS
SELECT
product_variations.product_id AS product_id,
product_variations.id AS product_variation_id,
COALESCE(SUM(stocks.quantity) - COALESCE(SUM(product_variation_order.quantity), 0), 0) AS stock,
CASE WHEN COALESCE(SUM(stocks.quantity) - COALESCE(SUM(product_variation_order.quantity), 0), 0) > 0
THEN true
ELSE false
END in_stock
FROM product_variations
LEFT JOIN(
SELECT stocks.product_variation_id AS id,
SUM(stocks.quantity) AS quantity
FROM stocks
GROUP BY stocks.product_variation_id
) AS stocks USING (id)
LEFT JOIN (
SELECT
product_variation_order.product_variation_id AS id,
SUM(product_variation_order.quantity) AS quantity
FROM product_variation_order
GROUP BY product_variation_order.product_variation_id
) AS product_variation_order USING (id)
GROUP BY product_variations.id
MySQL said:
#1349 – View’s SELECT contains a subquery in the FROM clause
2
Answers
upgrade to mysql-8 and my problem is solved.
I found the solution here http://www.mynotebucket.com/update-mysql-under-xmpp/
You need to upgrade your MySQL. If for any reason you are unable to do so, you can create views for the subqueries and integrate them into your query.