# qryImputeCountyFromCity.sql # SQL # n6lhv@arrl.net (Wayne Smith) # Display the MySQL version SELECT version(); # Switch to the correct database USE uls # Create any index so we don't have to do multiple, sequential (slow) table scans ALTER TABLE pubacc_lo ADD INDEX(location_city); # Change the value UPDATE pubacc_lo SET location_county = 'ALAMEDA' WHERE (location_county = '') AND ( location_city = 'BERKELEY' OR location_city = 'OAKLAND' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'BUTTE' WHERE (location_county = '') AND ( location_city = 'PARADISE' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'CONTRA COSTA' WHERE (location_county = '') AND ( location_city = 'MT DIABLO' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'DEL NORTE' WHERE (location_county = '') AND ( location_city = 'CRESCENT CITY' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'FRESNO' WHERE (location_county = '') AND ( location_city = 'FRESNO' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'HUMBOLDT' WHERE (location_county = '') AND ( location_city = 'ARCATA' OR location_city = 'EUREKA' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'KERN' WHERE (location_county = '') AND ( location_city = 'BAKERSFIELD' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'LASSEN' WHERE (location_county = '') AND ( location_city = 'SUSANVILLE' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'LOS ANGELES' WHERE (location_county = '') AND ( location_city = 'LONG BEACH' OR location_city = 'LOS ANGELES' OR location_city = 'SANTA CATALINA ISLD' OR location_city = 'WEST COVINA' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'MADERA' WHERE (location_county = '') AND ( location_city = 'CHOWCHILLA' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'MENDOCINO' WHERE (location_county = '') AND ( location_city = 'GUALALA' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'MERCED' WHERE (location_county = '') AND ( location_city = 'ATWATER' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'MONTEREY' WHERE (location_county = '') AND ( location_city = 'SALINAS' OR location_city = 'KING CITY' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'ORANGE' WHERE (location_county = '') AND ( location_city = 'SANTA ANA' OR location_city = 'SANTIAGO PEAK' OR location_city = 'TUSTIN' OR location_city = 'HUNTINGTON BEACH' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'RIVERSIDE' WHERE (location_county = '') AND ( location_city = 'PALM SPRINGS' OR location_city = 'RIVERSIDE' OR location_city = 'THERMAL' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'SACRAMENTO' WHERE (location_county = '') AND ( location_city = 'SACRAMENTO' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'SAN BERNARDINO' WHERE (location_county = '') AND ( location_city = 'BIG BEAR LAKE' OR location_city = 'ONTARIO' OR location_city = 'SAN BERNARDINO' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'SAN DIEGO' WHERE (location_county = '') AND ( location_city = 'LA JOLLA' OR location_city = 'RAMONA' OR location_city = 'SAN DIEGO' OR location_city = 'SANTEE' OR location_city = 'OCEANSIDE' OR location_city = 'OTAY' OR location_city = 'JAMUL' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'SAN FRANCISCO' WHERE (location_county = '') AND ( location_city = 'SAN FRANCISCO' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'SAN JOAQUIN' WHERE (location_county = '') AND ( location_city = 'LODI' OR location_city = 'STOCKTON' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'SAN LUIS OBISBO' WHERE (location_county = '') AND ( location_city = 'SAN LUIS OBISBO' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'SANTA BARBARA' WHERE (location_county = '') AND ( location_city = 'SANTA BARBARA' OR location_city = 'SANTA MARIA' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'SANTA CLARA' WHERE (location_county = '') AND ( location_city = 'MT LOMA PIRETA' OR location_city = 'MT LOMA PRIETA' OR location_city = 'SAN JOSE' OR location_city = 'SUNNYVALE' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'SANTA CRUZ' WHERE (location_county = '') AND ( location_city = 'SANTA CRUZ' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'SHASTA' WHERE (location_county = '') AND ( location_city = 'REDDING' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'SONOMA' WHERE (location_county = '') AND ( location_city = 'SANTA ROSA' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'STANISLAUS' WHERE (location_county = '') AND ( location_city = 'TURLOCK' OR location_city = 'MODESTO' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'TULARE' WHERE (location_county = '') AND ( location_city = 'PORTERVILLE' OR location_city = 'TULARE' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'TUOLUMNE' WHERE (location_county = '') AND ( location_city = 'TUOLUMNE ' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'VENTURA' WHERE (location_county = '') AND ( location_city = 'VENTURA' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'YOLO' WHERE (location_county = '') AND ( location_city = 'DAVIS' ) ; # Change the value UPDATE pubacc_lo SET location_county = 'YUBA' WHERE (location_county = '') AND ( location_city = 'MARYSVILLE' ) ; # Create any index so we don't have to do multiple, sequential (slow) table scans ALTER TABLE pubacc_lo DROP INDEX location_city;