Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8999751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:13:18+00:00 2026-06-16T00:13:18+00:00

I have a table with double foreign key reference to gebruikersid and now I’m

  • 0

I have a table with double foreign key reference to gebruikersid and now I’m kind of in a mess. First of all a “gebruiker” is a “user” in dutch, to avoid miscommunications.

The query I’m using now is:

$uploadeditems = "
                SELECT *
                FROM file f
                    INNER JOIN gebruikers g on f.empid = g.gebruikersid
                WHERE g.gebruikersid = ".$GET['employeeid']."
                ";

But what I actually would need to make is this something like this:

        $uploadeditems = "
                        SELECT *
                        FROM file f
                            INNER JOIN gebruikers on f.empid = gebruikers.gebruikersid as 'gebruikers.employee'
                            INNER JOIN gebruikers on f.gebruikersid = gebruikers.gebruikersid as 'gebruikers.uploader'
                        WHERE gebruikers.employee= ".$GET['employeeid']."
                        ";

Short about the code so you get my point:

Table FILE has gebruikersid, who is the uploader of the file and empid, the one on whose this file has to be linked. (both FK of gebruiker.gebruikersid).

So for instance I have in my database:

fileid  filename    filesize    filepath           custid   empid   gebruikersid    filedescription

228     Test.         60    files/employees/113/    NULL     113    70  

So what I’m basically am trying is to have two references:

When I’m inner joining by f.empid I want to be able to return the username of the f.empid & gebruiker.gebruikersid reference, and with the same time I want to be able to return the username of the f.gebruikersid & gebruikers.gebruikersid reference, so what I could have return would be like:

File list of user X:
File A, uploaded by user Y.
File B, uploaded by user Z.
and so on…

Now I get:
File list of user X:
File A, uploaded by user X.
File B, uploaded by user X.
even when it’s all good in the database.

EDIT Since I had an employee table before (and now all employees are users) my code names are messed up, it might be a little harder sorry. need to figure this all out once I can move on.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:13:18+00:00Added an answer on June 16, 2026 at 12:13 am

    If you join to the same table more than once, than you need to use an alias for at least one of the instances. Then you must use the alias to prefix all the fields you select from the tables.

    For example:

    SELECT f.*, employee.FIELD1 as e_FIELD1, uploader.FIELD1 as u_FIELD1 ...
    
    FROM   file f
    
           INNER JOIN gebruikers as employee
           on f.empid = employee.gebruikersid
    
           INNER JOIN gebruikers as uploader
           on f.gebruikersid = uploader.gebruikersid
    
    WHERE gebruikers.employee= ".$GET['employeeid']."
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to have categories in my budget2000 table be the foreign key
I have table which contains double values stored in mysql database ...I need to
I have a date_dimension table definition: CREATE TABLE date_dimension ( id integer primary key,
I have a table with the following attributes: MyTable: - double longitude - double
I have a table and I want to hide a column when I double
I have a table which looks something like this sell_price double buy_price double time
I have a table column which some values are double or triple written. I
I have a table with 100 rows with double as data a1 a2 a3...
ok here it is. i have a table product with foreign keys from product_sizes,brands,categories,
I have a table like so: order_id INT product_id INT average_price DOUBLE other_price DOUBLE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.