Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)

I am having 4 tables to join in the SQL Server and I also need to show Specific Columns in Data Grid View.

First Table : emp_details

enter image description here

Second Table : tbl_designation

enter image description here

Third Table: tbl_empcontribution

enter image description here

Fourth table: tbl_empdeduction

enter image description here

Columns that need to be shown in Data Grid View is

1.From the first table, I need to show emp_id, emp_name , emp_pf

2.From the second table, I need to show designation_name

3.From the third table, I need to show pfacc1 and pfacc2

4.From the Fourth table, I need to show pf_percent and pf_max

Can anyone help with this?

1 Answer

0 votes
by (12.7k points)
edited by

You should consider having your naming conventions consistent because this helps visually and reduce bugs when writing code. Following is the query you need:

SELECT ed.emp_id, ed.emp_name , ed.emp_pf, emd.designation_name, te.pfacc1, te.pfacc2, temp. pf_percent, temp.pf_max

FROM dbo.emp_details AS ed

LEFT JOIN dbo.emp_designation AS emd ON emd.designation_id = ed.emp_designation 

LEFT JOIN dbo.tbl_empcontribution AS te ON te.eid = ed.emp_id

LEFT JOIN dbo.tbl_empdeduction AS temp ON temp.eid = ed.emp_id

If you want to explore more about SQL then do check out the SQL Certification course.

If you want to know more about Left Join, refer to the below SQL Left Join tutorial video that will help you out in a better way:

Related questions

0 votes
1 answer
0 votes
1 answer
+2 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...