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%';
  1. A. Ravi, Meena, Lata, Kiran
  2. B. Asha, Meena, Lata
  3. C. Ravi, Lata
  4. 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

Exams that ask this topic