Field Manual PHP / Laravel reference
← SQL

SELECT

SELECT projects columns from rows.

What it is

SELECT projects columns from rows.

When to use it

Read only fields needed by the use case.

Syntax

SELECT id, name FROM users;

Example

SELECT id, user_id, total_cents, status
FROM orders
WHERE status = 'pending'
ORDER BY id
LIMIT 20;

Common mistakes

SELECT * can expose sensitive fields and couple code to schema.

Related topics

Browse SQL