Example 1
Take the first three letters of a code
This example reads the first three characters and ignores the remainder of the source string.
Source table data Rows loaded before the example query runs.
Setup
CREATE TABLE products (sku VARCHAR(20));
INSERT INTO
products (sku)
VALUES
('ABC-123');Validated query Shared across supported engines.
SQL
SELECT
SUBSTRING(sku, 1, 3) AS sku_prefix
FROM
products;Expected result Returned rows for the shared example.
| sku_prefix |
|---|
| ABC |
Each supported engine accepts the same `SUBSTRING` call used here.