On Wednesday, October 29, 2003 8:20 AM Robb Kerr wrote: > I am attempting to hack a tutorial from the Zend site. I have found the > tutorial/project to be excellent, but I don't completely understand what's > being done in the following Query statement. > > //query database, assemble data for selectors > $Query = "SELECT s.ID, s.Name, a.Code " . > "FROM areacode a, state s " . > "WHERE a.State = s.ID " . > "ORDER BY s.Name, a.Code";
Hey Rob. In plain english, what this query is doing is the following: Selecting ID, Name and Code from the areacode and state tables, where the State in the areacode table is equal to the ID in the state table. You are correct in assuming that the "s" in "s.Name" and the "a" in "a.Code" reference the table from which these fields are retrieved. So from this, the "a" following the "areacode" table and the "s" following the "state" table are basically shortcuts for referring to these tables, as per your assumption. You could leave it just as "FROM areacode, state" and reference the fields as "state.ID" and "areacode.Code", but this is much more cumbersome. Not sure I understand what you're asking when you refer to being unable to find the ID, Name and Code variables initiated in the preceding code. Can you elaborate on that a little? Cheers, Pablo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php