开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜