RIGHT()() — SQL Technical Interview Questions & Answers
RIGHT()()
RIGHT()()
- RIGHT() last n characters. You use it in SELECT (and sometimes WHERE/UPDATE). It does not change stored data unless you UPDATE … SET col = RIGHT(col).
- Board: SELECT RIGHT(name, 2) FROM students; Run it. Say the result out loud. If the column is NULL, the result is often NULL — wrap with IFNULL if you need a blank instead.
- String indexes in MySQL start at 1, not 0 (SUBSTR, INSTR, LEFT). Not RIGHT JOIN.
- Interview: name RIGHT, one argument list, one example on the students table. Don’t recite every string function.
- On the example next to this theory: RIGHT()() — jOIN combines rows using a match condition between tables.
Technical Interview Tip: Say what RIGHT returns, then SELECT RIGHT(name, 2) FROM students;
Code Examples for RIGHT()()
RIGHT()() — sample query
CREATE TABLE customers (id INTEGER PRIMARY KEY, name TEXT);
CREATE TABLE orders (id INTEGER PRIMARY KEY, customer_id INTEGER, total INTEGER);
INSERT INTO customers VALUES (1, 'Asha'), (2, 'Ravi');
INSERT INTO orders VALUES (10, 1, 500), (11, 1, 200);
SELECT c.name, o.total
FROM customers c
JOIN orders o ON o.customer_id = c.id;RIGHT()() — jOIN combines rows using a match condition between tables.
How to Explain RIGHT()() to an Interviewer
What does RIGHT do?
last n characters SELECT RIGHT(name, 2) FROM students;
Does it UPDATE the table?
No, unless you write UPDATE SELECT only prints