# qryOrgBigRetail.sql # SQL # n6lhv@arrl.net (Wayne Smith) # Display the MySQL version SELECT version(); # Switch to the correct database USE uls # delete the table if it exists (it probably does) DROP TABLE IF EXISTS tblOrgBigRetail; # Join the relevant data into a "flat" table CREATE TABLE tblOrgBigRetail #EXPLAIN SELECT DISTINCT * FROM tblGeoStateCA WHERE (entity_name LIKE '%TARGET%' AND NOT (entity_name LIKE '%PEST%')) OR (entity_name LIKE '%TOYS%' AND NOT (entity_name LIKE '%MATTEL%' OR entity_name LIKE '%DIST%' OR entity_name LIKE '%DISCOVERY%')) OR ((entity_name LIKE '%WAL%' AND entity_name LIKE '%MART%') AND NOT (entity_name LIKE '%DISTRIBUTION%')) OR (entity_name LIKE '%CIRCUIT%' AND entity_name LIKE '%CITY%') OR ((entity_name LIKE '%BEST%' AND entity_name LIKE '%BUY%') AND NOT (entity_name LIKE '%MARKET%')) ORDER BY frequency_assigned, call_sign, radio_service_code, class_station_code, location_state, location_county, location_city, location_address ;