divinedesigns1 Posted July 9, 2012 Report Share Posted July 9, 2012 ok may be im not reading this correctly but this query is weird and doesnt make sense at all, one the database that was created doesnt even go with the query, let me just show you $sql = "SELECT albums.album_id, albums.album_name, albums.album_desc, albums.album_cover, COUNT(photos.photo_id) as imagesFROM albums LEFT JOIN photos ON albums.album_id = photos.album_idGROUP BY albums.album_name, albums.album_descORDER BY albums.album_id ASC"; notice the albums.album_name, etc ok and this is the table use for the album CREATE TABLE album ( album_id int(11) NOT NULL auto_increment, album_name varchar(255) NOT NULL default '', album_desc text NOT NULL, album_cover varchar(255) NOT NULL default '', PRIMARY KEY (album_id), KEY album_name (album_name)) TYPE=MyISAM; now according to the tutorial, the above query suppose to get the images and albums from the database using that query, but to what i know, you shouldnt use dots to separate your words when naming your tables you suppose to use a underscoream i wrong?oo yeah its a tutorial for a photo album Link to comment Share on other sites More sharing options...
birbal Posted July 9, 2012 Report Share Posted July 9, 2012 (edited) SELECTalbums.album_id, albums.album_name, albums.album_desc, albums.album_cover, COUNT(photos.photo_id) as imagesFROM albumsLEFT JOIN photosON albums.album_id = photos.album_idGROUP BY albums.album_name, albums.album_descORDER BY albums.album_id ASCred parts are table names. they are joined using LEFT JOIN. two tables can have same field name so to avoid ambiguiation tables name are appended as part of database schema. dot is not colum or table name. albums.album_id tells look for alubums_id column which is in album table. http://www.google.co...Z1EsQEvlA1hMHPA Edited July 9, 2012 by birbal Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now