Jump to content

Distinct values with Joins


bbram

Recommended Posts

Joins in general are still hard for me to figure out, and I don’t know why. I have the following code in my PHPMyAdmin console, and keep getting an error message:

select DISTINCT login.username, login.login_time, players.Player_ID, players.Player_name, players.Player_First_Name, Players.Player_Last_Name, players.player_email INNER JOIN players on login.username=players.Player_ID where login.login_time > 2019-09-09

Basically I am trying to figure out the last people that have logged in to our system within the past year and then will max it out to a certain number like 1000, or 500 depending on what mail server we use.

Any help is greatly appreciated.

Link to comment
Share on other sites

This is your query in a more readable form

select DISTINCT 
    , login.username
    , login.login_time
    , players.Player_ID
    , players.Player_name
    , players.Player_First_Name
    , Players.Player_Last_Name
    , players.player_email
 
INNER JOIN players on login.username=players.Player_ID 
where login.login_time > 2019-09-09

It is missing "FROM login" where I left the empty line before "INNER JOIN".

Your date needs to be inside plain single quotes (not the single inverted quotes that your editor has used).

Are you sure you want to be joining a username with an id (usually numeric)?

If none of those help, show us the error message your are getting.

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.