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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.