USING and column names in SQL
When both sides name the column the same thing, USING says so once.
SELECT
order_id,
sku,
quantity,
price
FROM order_items
JOIN products
USING (sku)
ORDER BY order_id, sku;
How it works
USING (col)isON left.col = right.colwith less repetition.- The joined column appears once in the output, not twice.
- It only works when the names match, which is a reason to name them well.
Keywords and builtins used here
BYFROMJOINORDERSELECTUSING
The run, in numbers
- Lines
- 9
- Characters to type
- 104
- Tokens
- 22
- Three-star pace
- 85 tpm
At the three-star pace of 85 tokens a minute, this run takes about 16 seconds.
Step 3 of 9 in Joins, step 11 of 22 in Joins & aggregation.