#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.

Finished this topic?

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