#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
Step 10
4 min read

Row Subqueries

Query inside a query that returns ONE row with multiple columns.

What is a Row Subquery?

A row subquery returns one row with multiple columns.

Simple rule: Compare multiple values at once!

How Row Subquery Works

Basic Syntax

SELECT * FROM table WHERE (col1, col2) = (SELECT val1, val2 FROM ...);

Example 1: Find Exact Match

SELECT * FROM products WHERE (price, category) = (SELECT MAX(price), 'Electronics' FROM products);

Matches: price = MAX AND category = 'Electronics'

Example 2: Find Product with Max Price & Stock

SELECT * FROM products WHERE price = (SELECT MAX(price) FROM products) AND stock = (SELECT MAX(stock) FROM products);

Row Subquery Rules

  1. Returns ONE row - multiple columns
  2. Compare with = - must match all columns
  3. Less common - scalar subqueries used more often

Try It Below

Practice finding products with specific combinations!

What Comes Next

Next: Table Subqueries - return a full result set.

Find Max Price + Electronics

Row subquery returns (100, 'Electronics'). Find matching product!

Source Table: students
idnamepricecategory
1Phone100Electronics
2Shirt30Clothing
3Laptop80Electronics
4Pants50Clothing
4 rows
SQL Editor
Loading...

Filter by Category

Find all Electronics. Try: SELECT name, price FROM products WHERE category = 'Electronics';

Source Table: students
idnamepricecategory
1Phone100Electronics
2Shirt30Clothing
3Laptop80Electronics
4Pants50Clothing
4 rows
SQL Editor
Loading...

Finished this topic?

Mark it complete to track your progress and maintain your streak!

SkillsetMaster - AI, Web Development & Data Analytics Courses