php - Migrating from one table to another -
i have 2 tables, 1 100,000 records of data , 1 "not interested"
the table "businesses" has "businessid | around 10 other info columns
the table "notinterested" has "businessid" , dateofcall.
currently filtering out data checking if, if exists in notinterested , dateofcall less 42 days dont show in select. (code below).
select * businesses postcode '" . $pcode . "%' , businesstype '%$btype%' , businessid not in (select businessid telesales.notinterested now() between dateofcall , (dateofcall + interval 42 day) ) , appointmentdate null order rand() limit 100" it fine @ first "notinterested" has around 30,000 records getting sluggish 1 letter postcodes.
i have added new column bussinesses table called "notinterested" , want put date in there instead.
what easyiest way migrate dateofcall "notinterested" table new column in "businesses"? im bit worried live data , dont have time
to answer original question, can run query update added date field.
update businesses inner join (select businessid, max(dateofcall) maxdateofcall telesales.notinterested now() between dateofcall , (dateofcall + interval 42 day) group businessid) recentnotinterested on businesses.businessid = recentnotinterested.businessid set businesses.notinterested = recentnotinterested.maxdateofcall;
Comments
Post a Comment