PGoCareerGoCareer prep tools
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

SQL · Theory

Alias

← All stacks

Theory

306/439

Alias

Alias is a nickname. SELECT name AS student FROM students; column alias. FROM students AS s — table alias. Required when the same table is used twice or a derived table.

AS is optional — students s. Use aliases in JOIN … ON s.roll = m.roll so every column is qualified.

Trap: SELECT marks - 40 fail without quotes — fail looks like a column. AS fail or AS 'fail'. Trap: using the alias in WHERE (WHERE runs before SELECT aliases in MySQL — use HAVING or repeat the expression).

On the example next to this theory: Alias: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

Exam tip

SELECT name AS student FROM students s;

Alias — sample query

-- Alias
CREATE TABLE demo (
  id INTEGER PRIMARY KEY,
  label TEXT NOT NULL,
  qty INTEGER DEFAULT 0
);
INSERT INTO demo (id, label, qty) VALUES
  (1, 'alpha', 2),
  (2, 'beta', 5);
SELECT label, qty FROM demo WHERE qty >= 2 ORDER BY qty DESC;

Alias: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

Short notes

  • DefAlias = nickname for a column or table.
  • Rules and m in joins. AS optional.
  • TrapColumn alias in WHERE.

Questions

1

Why table aliases?

306 / 439

P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.