In this article, we will find out about SQL joins and going to get two tables together with it, to get the entire information from the two tables.
Joining two tables is an activity each back-end designer ought to approach. In light of the circumstances we face during improvement, the methodology for getting the records must be basic.
Presently the methodology is that, make a false name of the table and utilize that nom de plume to pick which fields you need to have. Points of interest are various also that you won’t have to utilize left or right or internal or external participate in any capacity which certainly makes question complex.
How about we comprehend the idea. The principal thing we ought to choose the tables we should finish our question. At that point, you ought to pick which field you need to have the outcome by utilizing the assumed name. The third thing is you should give a condition wherein the inquiry should choose result. For example, A.eid = B.eid.
This idea is especially valuable in the situations when you need to have an exceptionally tight hold on your outcome’s fields.
Underneath we have example unmistakably clarifying the ideas we have experienced. We will utilize the one of a kind keys in the main example. Watch out for how we can without much of a stretch pick the fields of the records while joining the tables.
Table (worker) having three fields and four information in it,
Id Name Address 100 Aman Mumbai 200 Arun Pune 300 Karan Delhi 400 Aman Mumbai
Table (users) having three fields and two data in it,
eid cid Name 100 100 Shubham 200 200 Abhishek
Presently, we have two tables in our database having various fields instead of one which is eid and now we are going to join both the tables in two different ways. The primary question is to discover entire information and second one is to choose information with a condition in it.
SELECT E1.name, E2.name FROM employee E1 , users E2;
SELECT E1.name, E2.name FROM employee E1 , users E2 WHERE E1.eid=E2.eid;