Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error in FROM clause union query

Status
Not open for further replies.

John1Chr

Technical User
Sep 24, 2005
218
US
Can you see the issue? Not sure why I am getting the error.

Select TABLE1.CTRRBVALUE,
TABLE1.CFATTRB,
TABLE1.DESCR,
TABLE1_1.CFATTRB,
TABLE1_1.CTRRBVALUE,
TABLE1_1.DESCR
from TABLE1
inner join TABLE1_1
where 0=1
UNION ALL Select
TABLE1.CTRRBVALUE,
TABLE1.CFATTRB,
TABLE1.DESCR,
TABLE1_1.CFATTRB,
TABLE1_1.CTRRBVALUE,
TABLE1_1.DESCR
from TABLE1
inner join TABLE1_1
TABLE1. CTRRBVALUE = substr(TABLE1 . CTRRBVALUE , 1, 2) and
TABLE1_1. CFATTRB = 'ACTIVITY' and
TABLE1.CFATTRB = 'PROGRAM';
 
Looks like your joins are missing the 'ON' Keyword and missing parts. Additionally it looks like you forgot to start your Where clause with Where in the second select.
 

Plus:[blue]
Select TABLE1.CTRRBVALUE,
TABLE1.CFATTRB,
TABLE1.DESCR,
TABLE1_1.CFATTRB,
TABLE1_1.CTRRBVALUE,
TABLE1_1.DESCR
from TABLE1
inner join TABLE1_1
where 0=1[/blue]
UNION ALL [red]Select
TABLE1.CTRRBVALUE,
TABLE1.CFATTRB,
TABLE1.DESCR,
TABLE1_1.CFATTRB,
TABLE1_1.CTRRBVALUE,
TABLE1_1.DESCR
from TABLE1
inner join TABLE1_1
TABLE1. CTRRBVALUE = substr(TABLE1 . CTRRBVALUE , 1, 2) and
TABLE1_1. CFATTRB = 'ACTIVITY' and
TABLE1.CFATTRB = 'PROGRAM'[/red];

You should be able to run the BLUE and RED selects independently, but can you?

In the BLUE select you join 2 tables on what? And the WHERE 0 = 1 will never give you any results back (unless in some universe 0 equals 1 :) )

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top