sseeley Posted January 27, 2012 Share Posted January 27, 2012 Please can you help, I have a really easy query but cannot get past this error message. SELECT cadetId, lastName, firstName FROM ( SELECT tblcadets.pkCadetId AS cadetId, tblcadets.lastName AS lastName, tblcadets.firstName AS firstName FROM tblcadets AS tblcadets ) thanks for any help you can give me. Quote Link to comment https://forums.phpfreaks.com/topic/255901-every-derived-table-must-have-its-own-alias/ Share on other sites More sharing options...
AyKay47 Posted January 27, 2012 Share Posted January 27, 2012 this query makes no sense.. SELECT tblcadets.pkCadetId AS cadetId, tblcadets.lastName AS lastName, tblcadets.firstName AS firstName FROM tblcadets AS tblcadets Quote Link to comment https://forums.phpfreaks.com/topic/255901-every-derived-table-must-have-its-own-alias/#findComment-1311817 Share on other sites More sharing options...
awjudd Posted January 27, 2012 Share Posted January 27, 2012 As AyKay47 said, your query is doing the exact same as just a straight SELECT on that table. However that said, to answer your question it is because you have a subquery so you need to alias that table in order for SQL to know what to refer to it as: SELECT cadetId, lastName, firstName FROM ( SELECT tblcadets.pkCadetId AS cadetId, tblcadets.lastName AS lastName, tblcadets.firstName AS firstName FROM tblcadets AS tblcadets ) AS a Quote Link to comment https://forums.phpfreaks.com/topic/255901-every-derived-table-must-have-its-own-alias/#findComment-1311820 Share on other sites More sharing options...
sseeley Posted January 27, 2012 Author Share Posted January 27, 2012 Thats great, thanks Quote Link to comment https://forums.phpfreaks.com/topic/255901-every-derived-table-must-have-its-own-alias/#findComment-1311833 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.