SELECT
a.NAME AS Emp_Name,
a.Id_Trip_Source AS Source,
b.Destination_Name AS Destination
FROM
Tbl_Employee a
LEFT OUTER JOIN Tbl_Destination b ON a.Id_Trip_Destination = b.Id_Destination
/
you do not specify of the SOURCE name is also stored in the destination table or in a separate "source" name table.
You would have to add LEFT OUTER JOIN to support the lookup to the SOURCE name
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
Member
1 Points
4 Posts
Please help Urgent SQL query
Sep 29, 2020 09:54 AM|Samkoukou|LINK
I am using Access database Please help me in SQL query
have 2 tables like below:
Tbl_Employee Tbl_Destination
--------------- --------------------
IdEmployee Id_Destination
Name Destination_Name
Id_Trip_Source
Id_Trip_Destination
I need help to output like Below
Emp_Name Source Destination
-----------------------------------------------------
John Doo Germany Canada
Tony Montana Brazil Egypt
Suzan Jimba Norway Sweeden
Destination (Egpt,Brazil,Canada) are stored in Tbl_Destination in the field Destination_Name
I am using Access Database and asp.net
Contributor
3532 Points
1348 Posts
Re: Please help Urgent SQL query
Oct 09, 2020 03:38 AM|Lannie|LINK
SELECT
a.NAME AS Emp_Name,
a.Id_Trip_Source AS Source,
b.Destination_Name AS Destination
FROM
Tbl_Employee a
LEFT OUTER JOIN Tbl_Destination b ON a.Id_Trip_Destination = b.Id_Destination
/
you do not specify of the SOURCE name is also stored in the destination table or in a separate "source" name table.
You would have to add LEFT OUTER JOIN to support the lookup to the SOURCE name
Contributor
4060 Points
1588 Posts
Re: Please help Urgent SQL query
Oct 13, 2020 06:57 AM|yij sun|LINK
Hi Samkoukou,
Accroding to your description,could you tell us what the relationship of two tables.
As far as I think,you could join two tables.However,these two tables must have primary key , foreign key and relationship.
Syntax:
More details,you could refer to below article:
https://docs.microsoft.com/en-us/office/client-developer/access/desktop-database-reference/left-join-right-join-operations-microsoft-access-sql
Best regards,
Yijing Sun