CS FundamentalsModerateHCL · Tech Mahindra pattern
Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2), (4, 'John', 'Sales', 40000, 1), (5, 'Kiran', 'IT', 90000, 2), (6, 'Dev', NULL, 45000, 4), (7, 'Lata', 'Sales', NULL, 4). Which names does this query return?
Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2), (4, 'John', 'Sales', 40000, 1), (5, 'Kiran', 'IT', 90000, 2), (6, 'Dev', NULL, 45000, 4), (7, 'Lata', 'Sales', NULL, 4).
Which names does this query return?
SELECT name FROM Emp WHERE name LIKE '_a%';
- A. Ravi, Meena, Lata, Kiran
- B. Asha, Meena, Lata
- C. Ravi, Lata
- D. Asha, Ravi, Lata
Correct answer: C. Ravi, Lata
_ matches exactly one character and % any number, so the second letter must be 'a': Ravi and Lata. Kiran's 'a' is fourth; names ending in 'a' would need '%a'.
More DBMS and SQL questions
- A candidate key is best described as:
- In an ER diagram, entity sets Student and Course are related by a many-to-many relationship Enrols that has an attribute grade. What is…
- Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2)…
- Which mechanism does a DBMS mainly rely on to guarantee durability of committed transactions?
- Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2)…
- Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2)…