mojito Posted May 22, 2006 Share Posted May 22, 2006 I would like to understand the syntax used here as i want to access after the field in the table called thumbname[code]select a.aid as AlbumID, a.Title as Title, a.pid as PictureID, p.thumbname as Picture, count(l.pid) as Cnt from albums a, pictures p, pictures l where a.aid = p.aid and a.pid = p.pid and a.aid = l.aid group by a.aid order by a.aid[/code]what is the "as" bit doing?im trying to loop through thus... while($album = mysql_fetch_array($mysql)) { echo $album[thumbname];thanks [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/10202-sql-question/ Share on other sites More sharing options...
ober Posted May 22, 2006 Share Posted May 22, 2006 The "AS" part creates an alias.So when you echo a field, you want to use the alias name instead of the actual field name (the part after the "as").echo $album['Picture']; Quote Link to comment https://forums.phpfreaks.com/topic/10202-sql-question/#findComment-38016 Share on other sites More sharing options...
mojito Posted May 22, 2006 Author Share Posted May 22, 2006 Thanks ober, thats really useful, butI can see that "a" is later said to be album and "p" is said to be pictures but the bit I also dont get is the "l" or "1" here..[code]pictures l where a.aid = p.aid and a.pid = p.pid and a.aid = l.aid group by a.aid[/code]thanks for sharing your knowledge with us. [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/10202-sql-question/#findComment-38058 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.