Unit 3, lesson 3 · SUBSTR
Pieces of text with SUBSTR
Where did each sign-up come from?
SUBSTR takes part of a value: SUBSTR(text, start, length). Positions start at 1, so SUBSTR('IG-0412', 1, 2) is 'IG' and SUBSTR('IG-0412', 4, 4) is '0412'. Leave out the length to take everything from the start position to the end.
SELECT name,
SUBSTR(name, 1, 5) AS short_name
FROM products;Your task
The first two letters of each referral code say where the sign-up came from: IG for Instagram, FB for Facebook, GO for Google and EM for email. List each sign-up's id, ref_code and those two letters, as source.
Tables you will use: signups
Try it in your browserFree, no sign-up. Your query is checked as you go.