FROM — SQL Technical Interview Questions & Answers

FROM

FROM

  • FROM students names the table (or view). SELECT cannot guess the table. Joins also live here: FROM students s JOIN marks m ON s.roll = m.roll.
  • Alias: FROM students AS s — s.name is shorter. Needed when two tables share column names.
  • Trap: FROM missing. Trap: FROM students, marks without ON — old comma join = CROSS JOIN.
  • On the example next to this theory: FROM — sELECT projects columns; WHERE filters; ORDER BY sorts.

Technical Interview Tip: FROM students. Joins belong in FROM … ON …

Code Examples for FROM

FROM — sample query

CREATE TABLE employees (id INTEGER PRIMARY KEY, name TEXT, dept TEXT, salary INTEGER);
INSERT INTO employees VALUES
  (1, 'Asha', 'Eng', 70000),
  (2, 'Ravi', 'Eng', 65000),
  (3, 'Neha', 'HR', 50000);
SELECT name, salary FROM employees WHERE dept = 'Eng' ORDER BY salary DESC;

FROM — sELECT projects columns; WHERE filters; ORDER BY sorts.

How to Explain FROM to an Interviewer

What does FROM do?

Names the table Joins are written here too