Jump to content

coupe-r

Members
  • Posts

    328
  • Joined

  • Last visited

    Never

Everything posted by coupe-r

  1. Wow. I really appreciate the time it took you to work this out for me... I will try this when I get home from work today. Thanks again!!
  2. I got it working with 3 different queries, but if someone could still help with a single query, that would be great. Here are the 3 queries that work right now: SELECT firstname, lastname, email, level, deactivated_on, updated_on, created_on, created_by, updated_by FROM users WHERE user_id = '".$page_user_id."' AND deleted_on IS NULL AND client_id = '".$_SESSION['client_id']."' SELECT CONCAT(firstname,' ', lastname) AS createdBy FROM users WHERE user_id = '".$row['created_by']."' AND deleted_on IS NULL AND client_id = '".$_SESSION['client_id']."' SELECT CONCAT(firstname,' ', lastname) AS UpdatedBy FROM users WHERE user_id = '".$row['updated_by']."' AND deleted_on IS NULL AND client_id = '".$_SESSION['client_id']."'
  3. Hi All, I have a page where you can create or edit user data. When you click the edit button, a box displays and tells you who and when that user was created AND who and when the user was updated last. The issue is that the 'createdBy' and 'updatedBy' names are not correct, because of my query. I'm guess this is because all this data is within the same table and I'm not joining any tables? Also, the created_by and updated_by fields are user_id's of the user who created or updated it. Thanks for the help in advance. SELECT firstname, lastname, email, level, deactivated_on, updated_on, created_on, (SELECT CONCAT( firstname,' ', lastname) FROM users WHERE user_id = created_by AND deleted_on IS NULL) As createdBy, (SELECT CONCAT( firstname,' ', lastname) FROM users WHERE user_id = updated_by AND deleted_on IS NULL) As UpdatedBy FROM users WHERE user_id = '".$page_user_id."' AND deleted_on IS NULL AND client_id = '".$_SESSION['client_id']."' -- USERS Table -- user_id INTEGER client_id INTEGER firstname VARCHAR(25) lastname VARCHAR(30) email VARCHAR(55) password VARCHAR(40) level TINYINT deactivated_on DATETIME* created_on DATETIME created_by INTEGER updated_on DATETIME* updated_by INTEGER* deleted_on DATETIME* deleted_by INTEGER*
×
×
  • 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.