1

I have three tables:

  • Users
  • Users_request
  • Users_applications

Table Users has the id column, that column is related on Users_request.id finally Users_request.id is related with Users_applications.id

I try to do:

Users table has a column called name and User_applications has application_name. I want to "print" only those columns with their rows through JOIN clause.

Desired Output:

 user| application_name|
-----|------------------
user1| application1
user2| application2
userN| applicationN

I have the next, but I want improve it not using hardcode Users_applications.id

SELECT Users.id, Users_applications.name 
  FROM Users, Users_applications 
 WHERE Users.id = 'User1' AND User_applications.id = n ;

Is there any other way to accomplish it, through only Users.id using JOIN clauses?

Thanks in advance.

0

Table Users has the id column, that column is related on Users_request.id finally Users_request.id is related with Users_applications.id

So Users.id = Users_request.id and Users_request.id = Users_applications.id which means that Users.id = Users_applications.id

Then you can do:

SELECT Users.id, Users_applications.name 
FROM Users INNER JOIN Users_applications  ON Users.id = Users_applications.id
WHERE Users.id = 'User1';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.