Consider two tables 'EMP' and 'PARKING':
EMP(S.No, Name, Dept);
PARKING(S.No, Name, Dept);
Which of the following query will display only those rows such that the attribute "name" in both the tables have the same value?
Consider two tables 'EMP' and 'PARKING':
EMP(S.No, Name, Dept);
PARKING(S.No, Name, Dept);
Which of the following query will display only those rows such that the attribute "name" in both the tables have the same value?
Solution
Listing both tables in the FROM clause separated by a comma makes a cross join (every EMP row paired with every PARKING row). The WHERE clause then keeps only the pairs where , so only rows with matching names are shown. This is the standard syntax of an implicit join.
Options 1, 2 and 3: "FROM EMP E and PARKING P" is invalid, since tables are separated by a comma (or JOIN), never by "and".
Options 1 and 2: GROUP BY groups rows by a column or expression and does not filter rows.
Option 3: HAVING filters groups after GROUP BY, and it is not the right clause for a row-level join condition.
Related questions:
2025: 3 June Shift 2
2026: 24 May Shift 1
2026: 18 May Shift 2
2025: 30 May Shift 2