What I'm doing here is to add a column (named outOfStock) to my existing table prod_info.
I used this query to generate my outOfStock table.
PHP Code:
SELECT prod_id, XS, S, Splus, M, L, XL FROM prod_info AS outOfStock WHERE
XS IS NULL &&
S IS NULL &&
Splus IS NULL &&
M IS NULL &&
L IS NULL &&
XL IS NULL
Then I used a LEFT JOIN to combine them.
PHP Code:
SELECT * FROM prod_info LEFT JOIN (
SELECT prod_id, XS, S, Splus, M, L, XL FROM prod_info AS outOfStock WHERE
XS IS NULL &&
S IS NULL &&
Splus IS NULL &&
M IS NULL &&
L IS NULL &&
XL IS NULL
) ON prod_info.prod_id = outOfStock.prod_id
It prompts me this error message:
Every derived table must have its own alias.
I'm totally a goner at subqueries and joins. How does it mean and how do I achieve what I want?
Oh yes, please recommend some really simple reading on joins and subqueries. Most that I'd seen are quite difficult to understand.
Bookmarks