Displaying Data From Multiple Tables - Baskent.edu.tr

Transcription

Displaying Data fromMultiple TablesChapter 41

ObjectivesAfter completing this lesson, you should be able to do the following: Write SELECT statements to accessdata from more than one table usingequality and nonequality joins View data that generally does not meet ajoin condition by using outer joins Join a table to itselfLesson AimThis lesson covers how to obtain data from more than one table, using thedifferent methods available.2

Cartesian Product A Cartesian product is formed when: A join condition is omitted A join condition is invalid All rows in the first table are joined toall rows in the second tableTo avoid a Cartesian product, always include a valid join condition in aWHERE clause.3

Generating a Cartesian ProductSELECT ename, dnameFROM emp, ACCOUNTING56 Rows Selected4

What Is a Join?Use a join to query data from more than one table.Old SyntaxWrite the join condition in the WHERE clause.SELECTFROMWHEREtablel.column, table2. column2table1, table2tablel. columnl table2. column2;ANSI SyntaxWrite the join condition in the ON clause.SELECTtablel.column, table2. column2FROMtable1 INNER JOIN table2ONtablel. columnl table2. column2;Prefix the column name with the table name when the same column name appearsin more than one table.Defining JoinsWhen data from more than one table in the database is required, a join conditionis used. Rows in one table can be joined to rows in another table according tocommon values existing in corresponding columns, that is, usually primary andforeign key columns.TO display data from two or more related tables, write a simple join condition inthe WHERE clause, in the syntax:Table1.column1denotes the table and column from which data is retrievedTable1. column1 table2. column2 is the condition that joins (or relates) thetables together.5

Types of Joins Equijoin Non-equijoin Outer join Self join6

Types of JoinsThere are two main types of join conditions: Equijoins Non-equijoinsAdditional join methods include the following Outerjoins Selfjoins Set OperatorsNote: Set operators are not covered in this course . They are covered in anotherSQL course.7

What Is an Equijoin?EquijoinsTo determine the name of an employee’s department, you compare the value inthe DEPTNO column in the EMP table with the DEPTNO values in the DEPTtable.The relationship between the EMP and DEPT table is an equijoin - that is,values in the DEPTNO column on both tables must be equal.Frequently, this type of join involves primary and foreign key complements.Note: Equijoins are also called simple joins or innerjoins.Obtaining Data from Multiple TablesSELECT e.empno, e.deptno, d.locFROM emp e, dept dWHERE e.deptno d.deptno;Data from Multiple TablesSometimes you need to use data from more than one table. In the slide example,the report displays data from two separate tables. EMPNO exists in the EMP table DEPTNO exists in both the EMP and DEPT the Tables. LOC exists in the DEPT table.To prodııce the report. you need to link EMP and DEPT tables and access datafrom both of them.8

ANSI SyntaxSELECT e.empno, e.deptno, d.locFROM emp e inner join dept don e.deptno d.deptno;9

Retrieving Records with EquijoinsSELECT EMP.EMPNO, EMP.ENAME, EMP.DEPTNO,DEPT.DEPTNO, DEPT.LOCFROM EMP, DEPTWHERE EMP.DEPTNO DEPT.DEPTNOEMPNOENAME7698 BLAKE7369 SMITH7499 ALLENDEPTNODEPTNO302030LOC30 CHICAGO20 DALLAS30 CHICAGO14 rows selected.Retrieving Records with Equijoinsin the slide examaple. The SELECT clause specifies the column names to retrieve:- employee name, employee number, and department number, whichare columns in the emp table- department number, department name, and location, which arecolumns in the DEPT table.The FROM clause specifies the two tables that the database must access:EMP tableDEPT tableThe WHERE clause specifies how the tables are to be joined:EMP.DEPTNO DEPT.DEPTNO10

Oualifying Ambiguous Column NamesUse table prefixes to qualify column names that are in multiple tables.Improve performance by using table prefixes.Distinguish columns that have identical names but reside in differenttables by using column aliases.Qualifying Ambiguous Column NamesYou need to gualify the names of the columns in the WHERE clause ""itli thetable names to avoid ambiguity without the table prefixes. the DEPTNO columncould be from either the DEPT table or the EMP table. It is necessary to add thetable prefix to execute your query.If there are no common column names between the two tables, there is no needto qualify the columns. Howevwr, you will gain improved performance by usingthe table prefix because you tell the Oracle Server exactly where to find thecolumns.11

EQUIJOINSELECT emp.empno, emp.ename, emp.deptno,dept.deptno, dept.locFROM emp, deptWHERE emp.deptno Dept.deptno;EMPNOENAME7698 BLAKE7369 SMITHDEPTNODEPTNO302014 rows selected.12LOC30 CHICAGO20 DALLAS

Using Table AliasesThe following two scripts are equivalent. In the second one table aliases are used.SELECT e.ename, e.deptno, d.dnameFROM emp e , dept dWHERE e.deptno d.deptno ;ENAMEBLAKESMITHDEPTNODNAME30 SALES20 RESEARCH14 rows selected.13

Additional Search ConditionsUsing the AND OperatorAdditional Search ConditionsIn addition to the join, you may have criteria for your WHERE clause. Forexample, to display King's employee number, name, department number, anddepartments localion, you need an additional condition in the WHERE clause.SELECT EMP.EMPNO, EMP.ENAME, EMP.DEPTNO,DEPT.DEPTNO, DEPT.LOCFROM EMP, DEPTWHERE EMP.DEPTNO DEPT.DEPTNOAND INITCAP(ename) 'King' ;EMPNOENAME7839 KINGDEPTNODEPTNO1014LOC10 NEW YORK

ANSI SsyntaxORACLE’da Inner Join ‘i yapanFROM emp e, dept d WHERE e.deptno d.deptnoyerineFROM emp e INNER JOIN dept dinner Join koşulu yazıldıktan sonra iki tablo arasında bağlantıyı kuranON e.deptno d.deptnokoşulu yazılır.Eğer, ayrıca satırlardan yeni süzme yapılacaksa WHERE ile istenen koşul konulabilir:WHERE INITCAP(ename) 'King' ;Biçimindeki koşul yazılabilir.ÖrnekSELECT e.empno, e.ename, e.deptno, d.deptno, d.locFROM emp e INNER JOIN dept dON e.deptno d.deptnoWHERE INITCAP(ename) 'King' ;EMPNOENAME7839 KINGDEPTNODEPTNO10LOC10 NEW YORK15

Non-EquijoinsThe relationship between the EMP table and the SALGRADE table is a non-equijoin,meaning that no column in the EMP table corresponds directly to a column in theSALGRADE table.The relationship between the two tables is that the SAL column in the EMP table is betweenthe LOSAL and HISAL column of the SALGRADE table.The relationship is obtained using an operator other than equal ( ).SELECT*FROM emp ;EMPNO ENAMEJOBMGR HIREDATE SAL COMM DEPTNO7698 BLAKE MANAGER 7839 01/05/198128503014 rows selected.SELECT*FROM salgrade ;GRADELOSAL12345HISAL70012011401200130015 rows selected.1612001400200030009999

Retreive records where Salary in the EMP table is between low salary and highsalary in the SALGRADE table.SELECT e.ename, e.sal, s.gradeFROM EMP e, SALGRADE sWHERE e.salBETWEEN s.losal AND s.hisal ;ENAMESMITHJAMESSALGRADE80095014 rows selected.1711

ANSI SyntaxSELECT e.ename, e.sal, s.gradeFROM EMP e INNER JOIN SALGRADE sON e.salBETWEEN s.losal AND s.hisal ;ENAMESMITHJAMESSALGRADE80095014 rows selected.1811

Joining More Than Two TablesSELECT e.ename, e.deptno, d.dname, s.gradeFROM emp e, dept d, salgrade sWHERE e.deptno d.deptno ANDe.sal BETWEEN s.losal AND hisal;ENAMEDEPTNODNAMEGRADEKING10 ACCOUNTING5CLARK10 ACCOUNTING4MILLER10 ACCOUNTING2FORD20 RESEARCH4SCOTT20 RESEARCH4JONES20 RESEARCH4ADAMS20 RESEARCH1SMITH20 RESEARCH1BLAKE30 SALES4ALLEN30 SALES3TURNER30 SALES3MARTIN30 SALES2WARD30 SALES2JAMES30 SALES114 rows selected.19

ANSI SyntaxSELECT e.ename, e.deptno, d.dname, s.gradeFROM salgrade s, emp e INNER JOIN dept dON e.deptno d.deptnoWHEREe.sal BETWEEN s.losal AND s.hisal;ENAMEDEPTNODNAMEGRADEKING10 ACCOUNTING5CLARK10 ACCOUNTING4MILLER10 ACCOUNTING214 rows selected.20

Retrieving Records with Non-EquijoinsSELECT e.ename, e.sal, s.gradeFROM EMP e, SALGRADE sWHERE e.sal e.comm 12501111222239 rows selected.Non-Equijoins (continued)The slide example creates a non-equijoin to evaluate an employee's salary grade. The salarymust be between any pair of the low and high salary ranges.It is important to note that all employees appear exactly once when this query isexecuted. No employee is repeated in the list. There are two reasons for this:None of the rows in the salary grade table contain grades that overlap. That is, thesalary value for an employee can only lie between the low salary and high salaryvalues of one of the rows in the salary grade table.All of the employees' salaries lie within the limits provided by the salary grade table.That is, no employee earns less than the lowest value contained in the LOSAL column ormore than the highest value contained in the HISAL column.Note: Other operators such as and could be used, but BETWEEN is the simplest.Remember to specify the low value first and the high value last when using BETWEEN.Table aliases have been specified for performance reasons, not because of possible ambiguity.21

ANSI Syntax (Non Equijoin)SELECT e.ename, e.sal, s.gradeFROM EMP e INNER JOIN SALGRADE sON e.sal e.comm s.hisal RMARTINGRADE1600125012501500160012501250150012509 rows selected.22111122223

Outer joinsWhen two tables are joined with an inner join, data will only be returned ifmatching data exists in both tables. An outer join is like saying "and also includethe rows from one table if there are no matching rows in the other one."With an outer join the columns from the table where data is "missing" arereturned as NULL values.Outer joins come in two basic flavours, called Left and Right. Left outer joinsmean that the data must be contained in the table defined to the left side of theequivalence, but not necessarily the right hand side. Right outer joins, of course,work the other way around.To illustrate this, cut and paste the code below into a Query Analyser windowand try running it. I have used the newer ANSI syntax here, and the olderequivalents are included but commented out using the "--" comment notation.Comment them back in if you want to try them.23

Outer JoinsReturning Records with No Direct Match with Outer JoinsIf a row does not satisfy a join condition, the row will not appear in the queryresult. For example, in the equijoin condition of EMP and DEPT tables,department OPERATIONS does not appear because no one works in thatdepartment.SELECT e.ename , e.deptno, d.dnameFROM emp e, dept dWHEREe.deptno d.deptno;ENAMEDEPTNODNAMEBLAKE30 SALESSMITH20 RESEARCHALLEN30 SALESWARD30 SALESJONES20 RESEARCHMARTIN30 SALESCLARK10 ACCOUNTINGSCOTT20 RESEARCHKING10 ACCOUNTINGTURNER30 SALESADAMS20 RESEARCHJAMES30 SALESFORD20 RESEARCHMILLER10 ACCOUNTING14 rows selected.No employee in the OPERATIONS department24

Outer JoinsReturning Records with No Direct Match with Outer JoinsIf a row does not satisfy a join condition, the row will not appear in the queryresult. For example, in the equijoin condition of EMP and DEPT tables,department OPERATIONS does not appear because no one works in thatdepartment.Outer Joins (Old usage)You use an outer join to also see rows that do not usually meet thejoin condition.Outer join operator is the plus sign ( ).SELECTFROMWHEREtablel.column, table2. columntablel, table2tablel.column( ) table2.column;SELECT tablel.column, table2.columnFROMtablel, table2WHEREtablel.column. table2. column { ) ;Returning Records with No Direct Match with Outer JoinsThe missing row(s) can be returned if an outerjoin operator is used in the joincondition. The operator is a plus sign enclosed in parenthesis ( ), and it is placedon the "side" of the equality that the join rhctt a defıcient in mfürmcınun. Thisoperator has the effect of creating one or more mil l rows, to which one or morerows from the nondeficient table can be joined in the syntax.In the condition that joins (or relates) the lables together, is the outer joinsymbol, which can be placed on either side of the WHERE clause condition, butnot on both sides (Place the outer join symbol following the name of the columnin the table without the matching rows.)25

Old UsageSELECT e.ename, e.deptno, d.dnameFROM emp e, dept dWHEREENAMEe.deptno( ) d.deptno;DEPTNODNAMESMITHALLEN20 RESEARCH30 JAMESFORDMILLER30203030102010302030201015 rows ERATIONS

ANSI Right Outer Join SyntaxSELECT e.ename, e.deptno, d.dnameFROM emp e RIGHT OUTER JOIN dept NGTURNERADAMSJAMESFORDMILLERe.deptno d.deptno;DEPTNODNAME203030203030102010302030201015 rows HACCOUNTINGOPERATIONS

ANSI Left Outer Join SyntaxSELECT e.ename, e.deptno, d.dnameFROM emp e RIGHT OUTER JOIN dept NGTURNERADAMSJAMESFORDMILLERe.deptno d.deptno;DEPTNODNAME203030203030102010302030201014 rows HACCOUNTING

Old usageSELECT e.ename, e.deptno, d.dnameFROM emp e, dept dWHEREENAMEe.deptno d.deptno( );DEPTNODNAMESMITHALLEN20 RESEARCH30 JAMESFORDMILLER30203030102010302030201014 rows CHACCOUNTINGSALESRESEARCHSALESRESEARCHACCOUNTING

OUTER JOINPreviously, we had looked at left join, or inner join, where we select rows common to theparticipating tables to a join. What about the cases where we are interested in selectingelements in a table regardless of whether they are present in the second table? We will nowneed to use the SQL OUTER JOIN command.The syntax for performing an outer join in SQL is database-dependent. For example, inOracle, we will place an "( )" in the WHERE clause on the other side of the table for whichwe want to include all the rows.Let's assume that we have the following two tables,Table Store Informationstore nameLos AngelesSan DiegoLos AngelesBostonSales 1500 250 300 9region nameEastEastWestWeststore nameBostonNew YorkLos AngelesSan DiegoTable Geographyand we want to find out the sales amount for all of the stores. If we do a regular join, we willnot be able to get what we want because we will have missed "New York," since it does notappear in the Store Information table. Therefore, we need to perform an outer join on thetwo tables above:30

OUTER JOINSELECT A1.store name, SUM(A2.Sales) SALESFROM Geography A1, Store Information A2WHERE A1.store name A2.store name ( )GROUP BY A1.store nameNote that in this case, we are using the Oracle syntax for outer join.Result:store nameBostonNew YorkLos AngelesSan DiegoSALES 700 1800 250Note: NULL is returned when there is no match on the second table. In this case, "New York"does not appear in the table Store Information, thus its corresponding "SALES" column isNULL.31

ORDER BY usage in OUTER JOINSELECT e.ename, d.DEPTNO, d.dnameFROM emp e, dept dWHERE e.deptno( ) d.deptnoORDER BY e.deptno;ENAMEALLENWARDDEPTNODNAME30 SALES30 SALES40 OPERATIONS15 rows selected.32

ANSI Syntax for OUTER JOINSELECT e.ename, d.DEPTNO, d.dnameFROM emp e RIGHT OUTER JOIN dept dON e.deptno d.deptnoORDER BY 020202020203030303030304015 rows SSALESSALESOPERATIONS

Using Outer JoinsSELECT e.ename, d.DEPTNO, d.dnameFROM emp e, dept dWHERE e.deptno( ) d.deptnoORDER BY e.deptno;ENAMEDEPTNODNAMEMILLER10 ACCOUNTINGKING10 ACCOUNTINGCLARK10 ACCOUNTINGSMITH20 RESEARCHFORD20 RESEARCHADAMS20 RESEARCHSCOTT20 RESEARCHJONES20 RESEARCHTURNER30 SALESJAMES30 SALESALLEN30 SALESMARTIN30 SALESBLAKE30 SALESWARD30 SALES40 OPERATIONS15 rows selected.34

Joining a Table to ItselfSQL JOINNow we want to look at joins. To do joins correctly in SQL requires many of the elements wehave introduced so far. Let's assume that we have the following two tables,Table Store Informationstore nameLos AngelesSan DiegoLos AngelesBostonSales 1500 250 300 9Table Geographyregion nameEastEastWestWeststore nameBostonNew YorkLos AngelesSan Diegoand we want to find out sales by region. We see that table Geography includes information onregions and stores, and table Store Information contains sales information for each store. Toget the sales information by region, we have to combine the information from the two tables.Examining the two tables, we find that they are linked via the common field, "store name".We will first present the SQL statement and explain the use of each segment later:35

Joining a Table to ItselfSELECT A1.region name REGION, SUM(A2.Sales) SALESFROM Geography A1, Store Information A2WHERE A1.store name A2.store nameGROUP BY A1.region nameResult:REGIONEastWestSALES 700 2050The first two lines tell SQL to select two fields, the first one is the field "region name" fromtable Geography (aliased as REGION), and the second one is the sum of the field "Sales"from table Store Information (aliased as SALES). Notice how the table aliases are used here:Geography is aliased as A1, and Store Information is aliased as A2. Without the aliasing, thefirst line would becomeSELECT Geography.region name REGION,SUM(Store Information.Sales) SALESwhich is much more cumbersome. In essence, table aliases make the entire SQL statementeasier to understand, especially when multiple tables are included.Next, we turn our attention to line 3, the WHERE statement. This is where the condition ofthe join is specified. In this case, we want to make sure that the content in "store name" intable Geography matches that in table Store Information, and the way to do it is to set themequal. This WHERE statement is essential in making sure you get the correct output. Withoutthe correct WHERE statement, a Cartesian Join will result. Cartesian joins will result in thequery returning every possible combination of the two (or whatever the number of tables inthe FROM statement) tables. In this case, a Cartesian join would result in a total of 4 x 4 16rows being returned.36

Self JoinsMGR in the WORKER table is equal to EMPNO in the MANAGER table.SELECT WORKER.ename, WORKER.empno ,MANAGER.ename, MANAGER.empnoFROM emp WORKER, emp MANAGERWHERE WORKER.mgr MANAGER.empno ;ENAMEEMPNOENAMEEMPNOJAMES7900 BLAKE7698TURNER7844 BLAKE7698MARTIN7654 BLAKE7698WARD7521 BLAKE7698ALLEN7499 BLAKE7698FORD7902 JONES7566SCOTT7788 JONES7566MILLER7934 CLARK7782ADAMS7876 SCOTT7788CLARK7782 KING7839JONES7566 KING7839BLAKE7698 KING7839SMITH7369 FORD790213 rows selected.37

Self JoinsUse two alias for emp:SELECT e.ename, e.empno , m.ename, m.empnoFROM emp e, emp mWHERE e.mgr m.empno ;ENAMEEMPNOENAMEEMPNOJAMES7900 BLAKE7698TURNER7844 BLAKE7698MARTIN7654 BLAKE7698WARD7521 BLAKE7698ALLEN7499 BLAKE7698FORD7902 JONES7566SCOTT7788 JONES7566MILLER7934 CLARK7782ADAMS7876 SCOTT7788CLARK7782 KING7839JONES7566 KING7839BLAKE7698 KING7839SMITH7369 FORD790213 rows selected.38

ANSI Syntax for SELF JOINSELECT e.ename, e.empno , m.ename, m.empnoFROM emp e INNER JOIN emp mON e.mgr m.empno NGBLAKEKINGKINGJONESBLAKESCOTTBLAKEJONESCLARK13 rows 987788769875667782

SELF JOINSSELECT worker.ename 'works for ' manager.enameFROM emp worker, emp managerWHERE worker.mgr manager.empno;WORKER.ENAME 'WORKSFOR' MANAGER.ENAMESMITHworks for FORDALLENworks for BLAKEWARDworks for BLAKEJONESworks for KINGMARTINworks for BLAKEBLAKEworks for KINGCLARKworks for KINGSCOTTworks for JONESTURNERworks for BLAKEADAMSworks for SCOTTJAMESworks for BLAKEFORDworks for JONESMILLERworks for CLARK13 rows selected.Joining a Table to Itself (continued)The slide example joins the EMP table to itself. To simulate two tables in theFROM clause, there are two aliases, namely WORKER and MANAGER, forthe same table EMP.In this example, the WHERE clause contains the join that means ''where aworker's manager number matches the employee number for the manager.40

ANSI syntax for SELF JOINSSELECT worker.ename 'works for ' manager.enameFROM emp worker INNER JOIN emp managerON worker.mgr manager.empno;WORKER.ENAME 'WORKSFOR' MANAGER.ENAMESMITHworks for FORDALLENworks for BLAKEWARDworks for BLAKEJONESworks for KINGMARTINworks for BLAKEBLAKEworks for KINGCLARKworks for KINGSCOTTworks for JONESTURNERworks for BLAKEADAMSworks for SCOTTJAMESworks for BLAKEFORDworks for JONESMILLERworks for CLARK13 rows selected.41

Self JoinsSELECT e.ename, e.empno , m.ename, m.empnoFROM emp e, emp mWHERE e.mgr m.empno;ENAMEJAMESTURNEREMPNOENAME7900 BLAKE7844 BLAKEEMPNO7698769813 rows selected.Joining a Table to ItselfSometimes you need to join a table to itself. To find the name of eachemployee's manager, you need to join the EMP table to itself, or perform a selfjoin. For example, to find the name of Blake's manager, you need to:Find Blake in the EMP table by looking at the ENAME column.Find the manager number for Blake by looking at the MGR column.Blake's manager number is 7839. Find the name of the manager with EMPNO 7839 by looking at theENAME column. King's employee number is 7839, so King is Blake'smanager. In this process, you look in the table twice. The first time you look in the table tofind Blake in the ENAME column and MGR value of 7839. The second time youlook in the EMPNO column to find 7839 and the ENAME column to find KingANSI Syntax for Self JoinSELECT e.ename, e.empno , m.ename, m.empnoFROM emp e INNER JOIN emp mON e.mgr m.empno;42

SummarySELECT tablel. Column , table2. columnFROM tablel , table2WHERE tablel. columnl table2. column2; EquijoinNon-equijoinOuter joinSelf joinSummaryThere are multiple ways to join tables. The common thread, though, is that youwant to link them through a condition in the WHERE clause. The method youchoose will be based on the required result and the data structures that you areusing.43

ExercicesSolution 1SELECT e.ename, e.deptno, d.dnameFROM emp e , dept dWHERE e.deptno d.deptno ;Solution 2SELECT e.job, d.locFROM emp e , dept dWHERE e.deptno d.deptnoAND e.deptno 30;Solution 3SELECT e.ename, d.dname, d.locFROM emp e , dept dWHERE comm IS NOT NULLAND e.deptno d.deptno ;Solution 4SELECT e.ename, d.dname, d.locFROM emp e , dept dWHERE comm IS NOT NULLAND e.deptno d.deptno ;Solution 5SELECT e.ename, e.job, e.deptno, d.dnameFROM emp e, dept dWHERE e.deptno d.deptnoANDd.loc 'DALLAS' ;Solution 6SELECT e.ename "İşçi" , e.empno "İşçi No" ,m.ename "Manager" , m.empno "Mgr No"FROM emp e, emp mWHERE e.mgr m.empno ;Solution 7SELECT e.ename "İşçi" , e.empno "İşçi No" ,m.ename "Manager" , m.empno "Mgr No"FROM emp e, emp mWHERE e.mgr m.empno( ) ;44

Solution 8aSELECT e.deptno "Bölüm" , e.ename "İşçi" ,b.enameFROM emp e , emp bWHERE e.deptno b.deptnoORDER BY e.empno ;Solution 8bSELECT e.deptno "Bölüm" , e.ename "İşçi" ,b.enameFROM emp e , emp bWHERE e.deptno b.deptnoAND e.ename ! b.enameORDER BY e.empno ;Solution 8cSELECT e.deptno "Bölüm" , e.ename "İşçi" , b.enameFROM emp e , emp bWHERE e.deptno b.deptnoAND e.ename b.enameORDER BY e.deptno ;Solution 9aDESC salgrade;Solution 9bSELECT e.ename "İşçi" , e.job "İşi" , d.dname "Bölümü" ,e.sal "Maaş" , s.grade "Barem"FROM emp e, dept d , salgrade sWHEREe.deptno d.deptnoAND e.sal BETWEEN s.losal AND s.hisal ;Solution 10SELECT e.ename "İşçi" , e.hiredate "İşe Giriş Tarihi" , b.hiredate "Blake"FROM emp e, emp bWHEREe.hiredate b.hiredateAND b.ename 'BLAKE' ;Solution 11SELECT e.ename "İşçi" , e.hiredate "İşe Giriş Tarihi" , m.ename "Manageri" ,m.hiredate "Managerin Giriş Tar"FROM emp e, emp mWHEREe.hiredate m.hiredateAND e.mgr m.empno ;45

Cartesian Product A Cartesian product is formed when: A join condition is omitted A join condition is invalid All rows in the first table are joined to all rows in the second table To avoid a Cartesian product, always include a valid join condition in a