chris_davidsonuk Posted August 27, 2006 Share Posted August 27, 2006 I am creating a music website. Users must be verified by the admin before their songs are published on the site. I have 2 tables:[b]USERS[/b]- Username- Status (This is set to 1 if verified 0 if not)[b]TRACKS[/b]- UsernameI am wanting to query the database and show the tracks (from the tracks table) by users that have been verified (taken from the users table).I have looked at many tutorials but can't get this to word. Does anybody know the correct syntax for this query?Any help much appreciated. Quote Link to comment Share on other sites More sharing options...
Techbot Posted August 27, 2006 Share Posted August 27, 2006 Is this what you are after?SELECT tracks.*, status FROM tracks, users where user.status = 1;ps I don't see why username is in the tracks database should it be songname? Quote Link to comment Share on other sites More sharing options...
Techbot Posted August 27, 2006 Share Posted August 27, 2006 If you are using Username in both tables to do the join then trySelect * FROM tracks NATURAL JOIN users; Quote Link to comment Share on other sites More sharing options...
fenway Posted August 28, 2006 Share Posted August 28, 2006 Where are the UIDs? Tell me your primary key isn't a (VAR)CHAR field... that's a no-no, at least for MyISAM tables. Besides, you should use a proper JOIN:SELECT tracks.*FROM tracks INNER JOIN users ON ( tracks.username = user.username ) where user.status = 1; Quote Link to comment 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.