Unit 3, lesson 2 · LENGTH
How long is it? LENGTH
Referral codes of the wrong length
LENGTH counts the characters in a value, including spaces and punctuation. LENGTH('Desk mat') is 8. It is handy for checking codes, IDs and phone numbers that should always be the same size. The LENGTH of a missing value is NULL, so those rows drop out of any comparison. To find values that are not a given length, compare with <>, which means not equal (lesson 1.3).
SELECT name,
LENGTH(name) AS characters
FROM products
ORDER BY characters DESC;Your task
A valid referral code is exactly 7 characters, like 'IG-0412'. List the id and ref_code of every sign-up whose code is not 7 characters long. Leave out sign-ups that did not enter a code.
Tables you will use: signups
Try it in your browserFree, no sign-up. Your query is checked as you go.