LOAD DATA help (I need if/elseif/else syntax)
Posted: Wed Apr 11, 2007 6:32 pm
I have this query I am working on to import data from a text file into my mysql database. This is what I have so far:
Now I need a statement sort of like this (nested ternary):
I tried this but it does not work. Is there a way to do what I want?
Code: Select all
LOAD DATA LOCAL INFILE 'C:\\htdocs\\members.txt'
REPLACE
INTO TABLE `users`
FIELDS
TERMINATED BY '\t'
(@id, username, password, @passwordHint, first_name, last_name, middle_name, nick_name, spouse_name, @gender, @phone, @phone_b, @phone_c, @phone_type_a, @phone_type_b, @phone_type_c, @fax_a, @fax_b, @fax_type_a, @fax_type_b, @email, @email_b, @email_type_a, @email_type_b, @pref_contact, @date_join, @date_born, @date_resign, @address_a, @address_b, @city_a, @city_b, @zip_a, @zip_b, @state_a, @state_b, @address_type_a, @address_type_b, @image_ad, @image_name, business_website, @website_b, business_name, @business_classification, business_keywords, business_description, badge_number, @badge_plate, @full_perc, @badge_color, @team_id, @team_admin, @team_captain, @bio)
SET
gender = IF(@gender = 1, 'm', 'f')Code: Select all
home_phone = IF(@phone_type_a = 'Home', @phone_type_a, IF(@phone_tybe_b = 'Home', @phone_type_b, IF(@phone_type_c = 'Home', @phone_type_c, null)))