Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

double inner join in access db

I need to get some data from two tables, 1 people, 2 tasks, The following query in SQL works, and Access does not work

 SELECT     Task_Id,
            e2.emploeey_name AS W_FROM,
            e1.emploeey_name AS W_TO,
            t.Task_Details
 FROM       tasks AS T
 INNER JOIN Employees AS e1 ON e1.Emploeey_id = T.Task_To
 INNER JOIN Employees AS e2 ON e2.Emploeey_id = T.write_From

I tried many ways, and I searched in Google and I did not find an answer If anyone has a solution I would appreciate it very

like image 769
user1095549 Avatar asked Apr 26 '12 11:04

user1095549


People also ask

How do you inner join two tables in Access?

You create an inner join by dragging a field from one data source to a field on another data source. Access displays a line between the two fields to show that a join has been created. The names of the tables from which records are combined.

Can there be two inner joins in SQL?

Multiple inner joins in SQL are a common requirement for queries and are possible in SQL. You can add a join keyword to your query, specify the table and then the columns to join on. You can join many tables into a single query to get all of the data you need.

What are the 4 types of database joins?

Four types of joins: left, right, inner, and outer.

Can inner join have more rows?

Inner Join can for sure return more records than the records of the table. Inner join returns the results based on the condition specified in the JOIN condition. If there are more rows that satisfy the condition (as seen in query 2), it will return you more results. Reference: Introduction to Join – Visual Explanation.


1 Answers

Have you tried it with parentheses? MS Access requires (i.e. likes) parentheses around multiple JOINS:

 SELECT     Task_Id,
            e2.emploeey_name AS W_FROM,
            e1.emploeey_name AS W_TO,
            t.Task_Details
 FROM       
 (
      tasks AS T
      INNER JOIN Employees AS e1 
           ON e1.Emploeey_id = T.Task_To
 )
 INNER JOIN Employees AS e2 
      ON e2.Emploeey_id = T.write_From
like image 52
Taryn Avatar answered Oct 04 '22 20:10

Taryn