We have a database of loyalty card holders. I’m trying to write a simple SQL query that retrieves the full name of a customer based on his card number. However, I specifically need the output to be in the exact order I add the card numbers in. How can I implement this?
Here’s what I did.
SELECT cardnumber, first_name || ' ' || last_name FROM cardholder WHERE
cardnumber LIKE '%1111%' OR
cardnumber LIKE '%2222%' OR
cardnumber LIKE '%3333%'
I should add that I’m not very familiar with SQL, what I know now is pretty much the result of googling this particular problem in the past few days.
Your help is greatly appreciated.
(Also, I would be grateful for a way in which the card numbers can just be pasted into the code as a single block of text, but that’s only bonus.)
1 Answer