views:

172

answers:

2

I cant for the life of me figure out why this is erroring

A: 

It means exactly what it says - each derived table must have an alias. SELECT a.* FROM (SELECT ....)a

Update. This should work for you:

SELECT xxx.* FROM 
(
    SELECT ....
    FROM ....
    UNION
    (
       SELECT ....
       FROM .....
       LIMIT 46
    )
    LIMIT 50
)xxx
a1ex07
I am not sure what you mean...i tried to add it there are but now i get ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as a limit 0,50)' at line 144
Matt
Sorry, I didn't notice that one of your table has already had alias a.Use a different alias - `SELECT xxxx.* FROM (SELECT ....)xxxx`
a1ex07
And when you use alias for `SELECT ... FROM t1 JOIN t2 JOIN t3...` you should also enclose SELECT into brackets (`(SELECT ... FROM t1 JOIN t2 JOIN t3 ...) [AS] a`). It why it complaints on near 'as a limit 0,50)' at line 144"
a1ex07
A: 

The very first line of your query is

SELECT * FROM 

which appears to be unnecessary (as all three UNIONed queries already include SELECT and FROM clauses).

Removing this unnecessary line should resolve the problem; alternatively, adding a ( just after the first line, and adding a ) QRYALIAS at the end would also resolve the problem.

Mark Bannister