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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with NOT using aliases.

Status
Not open for further replies.

Petemush

Technical User
Jun 21, 2002
255
GB
I've a small piece of code that doesn't like me referencing a table directly but when I use an alias it's fine:


SELECT ret.RP_ID, SHORT_DESCR, RP_RP_ID_ARTL
FROM RETL_PRDS ret
WHERE ret.RP_ID = TEMP_SCODES.RP_ID OR ret.RP_RP_ID_ARTL = TEMP_SCODES.RP_ID
ORDER BY ret.RP_ID;


doesn't work

but

SELECT ret.RP_ID, SHORT_DESCR, RP_RP_ID_ARTL
FROM RETL_PRDS ret, TEMP_SCODES sco
WHERE ret.RP_ID = sco.RP_ID OR ret.RP_RP_ID_ARTL = sco.RP_ID
ORDER BY ret.RP_ID;


does. I know using an alias is better but any idea why this isn't working, I've an update statement as well where I can't use an alias and have to use seperate select statements to compare and it would be easier just to reference the table directly.

Any ideas?

Cheers,

Pete
 
Not to worry, I didn't realise you can't reference a table directly without putting it in scope first.

Cheers,

Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top