mysql query returns nothing (no error/empty table)
Why this query doesn’t working:
开发者_JS百科SELECT name
FROM
(
SELECT name
FROM table1
UNION
SELECT name
FROM table2
) q
It returns nothing, even no error or empty table.
But
SELECT name
FROM table1
UNION
SELECT name
FROM table2
Is ok. It returns table with name field full of rows from two tables.
I know that this query is redundant, but I need to make it work as part of other query.
There's nothing wrong with your query as is. Two tables, table1 and table2 with a column 'name' in each will work fine and return rows.
You said "I need to make it work as part of other [sic] query" are you testing the query you posted independently or only as part of the larger query? If it's the latter, then your problem is there, and not with what you posted.
精彩评论