I have the following query:
SELECT SUM( cost )
FROM (
SELECT s.cost
FROM sandwiches AS s
WHERE s.name = "Cheese Steak"
)
UNION (
SELECT p.cost
FROM pizza AS p
WHERE TYPE = "Plain"
AND SIZE = "L"
)
That gives me an error of:
#1248 - Every derived table must have its own alias
You need to alias your temp tables
SELECT SUM( cost )
FROM
(
(
SELECT s.cost
FROM sandwiches AS s
WHERE s.name = "Cheese Steak"
) AS T1
UNION
(
SELECT p.cost
FROM pizza AS p
WHERE TYPE = "Plain"
AND SIZE = "L"
) AS T2
) AS T
Do you want the whole Sum?
SELECT
( SELECT SUM(s.cost)
FROM sandwiches AS s
WHERE s.name = "Cheese Steak"
)
+
( SELECT SUM(p.cost)
FROM pizza AS p
WHERE p.TYPE = "Plain"
AND p.SIZE = "L"
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With