Al fin luego de tanto trabajar ya encontramos la contestación de este atascamiento que algunos de nuestros usuarios de este sitio presentan. Si deseas compartir algo no dudes en compartir tu conocimiento.
Ejemplo 1: cómo unir tablas en sql
JOINING 2TablesinsqlSELECT X.Column_Name , Y.Column_Name2
FROM TABLES1_NAME X
INNERJOIN TABLES2_NAME Y ON X.Primary_key = Y.Foreign_key;--FOR EXAMPLE--GET THE FIRST_NAME AND JOB_TITLE--USE EMPLOYEES AND JOBS TABLE--THE RELATIONSHIP IS JOB_IDSELECT E.FIRST_NAME , J.JOB_TITLE
FROM EMPLOYEES E
INNERJOIN JOBS J ON J.JOB_ID = E.JOB_ID;
Ejemplo 2: unir varias tablas sql
SELECT TableA.*, TableB.*, TableC.*, TableD.*FROM TableA
JOIN TableB
ON TableB.aID = TableA.aID
JOIN TableC
ON TableC.cID = TableB.cID
JOIN TableD
ON TableD.dID = TableA.dID
WHEREDATE(TableC.date)=date(now())
Ejemplo 3: unir tres tablas sql
Suppose we are having three table named as
Student_details
Attendance_details
Batch_details
And we have toapplyjoin these three tablesfor fetching records
Example query:
select column_names
from Student_detail as s join Attendance_details as a on
s.s_id = a.s_id join Batch_details as b on
s.s_id = b.s_id;
Here in the above example we implemented simplejoin but you change it with own join requirements.
Ejemplo 4: unir varias tablas en sql
SELECT Books_Namn, Author_Namn, Author_Age, Store_Namn FROM books
JOIN Author ON Author_Id = Author_Author_Id
JOIN Books_has_Store ON Books_Books_Id = Books_Id
JOIN Store ON Store_Id = Store_Store_Id;
Ejemplo 5: sql une 3 tablas
SELECTcolumn-names
FROMtable-name1 JOINtable-name2
ONcolumn-name1 =column-name2
WHERE condition
Ejemplo 6: 3 combinaciones en sql
SELECT e.FIRST_NAME ,-- coming from EMPLOYEES table
d.DEPARTMENT_NAME ,-- coming from DEPARTMENTS table
l.CITY ,-- coming from LOCATIONS table
c.COUNTRY_NAME ,-- coming from COUNTRIES table
r.REGION_NAME -- coming from REGIONS tableFROM EMPLOYEES e
INNERJOIN DEPARTMENTS d on e.DEPARTMENT_ID = d.DEPARTMENT_ID
INNERJOIN LOCATIONS l on l.LOCATION_ID = d.LOCATION_ID
INNERJOIN COUNTRIES c on l.COUNTRY_ID = c.COUNTRY_ID
INNERJOIN REGIONS r on c.REGION_ID = r.REGION_ID ;
Eres capaz de añadir valor a nuestro contenido informacional añadiendo tu veteranía en las explicaciones.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)