我有一個MySQL查詢選擇了多項紀錄MySQL的更新選擇
SELECT
leads.Affiliate_ID,
leads.first_name,
leads.last_name,
leads.email,
leads.loan_purpose,
leads.home_tel,
leads.mobile_tel,
leads.postcode,
leads.house_num,
leads.app_time,
leads.new_application_date,
leads.payment_accepted,
leads.sms
FROM
leads
WHERE
leads.Affiliate_ID = '23' AND
leads.sms IS NULL AND
leads.payment_accepted IS NULL AND
leads.new_application_date < (NOW() - INTERVAL 5 DAY)
我怎麼現在在所有選定的記錄更新leads.sms
到1
任何幫助或建議將是巨大
感謝所以它應該看起來像
SELECT leads.Affiliate_ID, leads.first_name, leads.last_name, leads.email, leads.loan_purpose, leads.home_tel, leads.mobile_tel, leads.postcode, leads.house_num, leads.app_time, leads.new_application_date, leads.payment_accepted, leads.sms FROM leads update leads set sms=1 WHERE leads.Affiliate_ID = '23' AND leads.payment_accepted IS NULL AND leads.sms IS NULL AND leads.new_application_date < (NOW() - INTERVAL 5 DAY)
或者我應該做我的選擇和prepossessing然後運行一個新的mysql命令來更新 – user1053865只是運行更新命令,它會更新所有選定的行,所以下一次執行選擇它應該返回沒有行導致sms列已更新(不再爲空)。 –
順便說一下,這是一個很好的做法,就像在更新之前對選擇查詢所做的那樣進行測試,因此您可以確定要更改哪些行。 –