I have table A whit this columns:
id name to_include
1 wanted1 null
2 wanted2 wanted1
If the query is for wanted2 then I need a way to use the value from to_include column (in this case wanted1) in the WHERE clause I have tried some like this:
SELECT * FROM (
SELECT * FROM A WHERE name = 'wanted2'
) AS B
UNION
SELECT * FROM A WHERE A.name = B.to_include
That got this error: Unknown column 'B.to_include' in 'where clause
Expected result: A recordset with both two rows from the example table.
JOINin one query and then combine that withUNION.