Jump to content

Join tables


chris_davidsonuk

Recommended Posts

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]
- Username

I 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.

Link to comment
https://forums.phpfreaks.com/topic/18797-join-tables/
Share on other sites

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;
Link to comment
https://forums.phpfreaks.com/topic/18797-join-tables/#findComment-81874
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.