A client asked us to run a query in a database for all registrations where the person was from an Arab country. First, I had to look up which countries qualify as an Arab country. Here is that list:
Algeria
Bahrain
Comoros
Djibouti
Egypt
Iraq
Jordan
Kuwait
Lebanon
Libya
Mauritania
Morocco
Oman
Palestine
Qatar
Saudi Arabia
Somalia
Sudan
Syria
Tunisia
United Arab Emirates
Yemen
Next I had to construct a query that would look for the people who registered using these countries. Since we store the two character country code, I had to convert this list into a list of country codes. Here is the final SQL statement.
SELECT r.regdate, p.lastname, p.firstname, p.country‘DZ’, ‘BH’, ‘KM’, ‘DJ’, ‘EG’, ‘IQ’, ‘JO’, ‘KW’, ‘LB’, ‘LY’, ‘MR’, ‘MA’, ‘OM’, ‘PS’, ‘QA’, ‘SA’, ‘SO’, ‘SD’, ‘SY’, ‘TN’, ‘AE’, ‘YE’
FROM `Registrations` AS r, `Persons` AS p
r.personid = p.id
AND p.country IN ()