SQL structure looks as follows: table (main_keywords) keyword_id, domain_id, user_id, keyword, redir 1, 1, 125, keyword 1, http://site.com/keyword-1 2, 1, 125, keyword 2, http://site.com/keyword-2 table (domains) domain_id, user_id, domain, username, template, ip_based, redir, keyword 1, 125, http://domain.info, user, 1, 1, http://site/keyword-1, keyword 1 I basically want to pull the redir from the table (domains) and change all of the corresponding entries in table (main_keywords)..corresponding meaning same domain_id. I have over 70,000 entries per server over 5 servers. Summary: Set table(main_keywords) redir for each keyword to match the domain redir URL found in table(domains). I have about 200-300 sites per server. 300-400 keywords per site. I basically want to change the keyword redirect pages to be the same as the main index page redirect url for each site. It's hard to explain but I'm willing to pay for this simple php script/sql query! My aim is charlesgmullen, e-mail = Thanks
I'm not sure which one you want from domains, but it would look something like this: (I haven't tested this in MySQL as I use MSSQL) UPDATE main_keywords SET redir = (SELECT domains.redir FROM domains WHERE main_keywords.domain_id = domains.domain_id) If you meant you wanted to get the domain, not the redir, from table(domains) then just swap domains.domain for domains.redir
I think you want to change the values in "main_keywords" of "domain_id" using the values in "table domains". Try this: (Please backup the databases first) <?php //connect to DB $mt= "main_keywords"; $md= "domains"; $q= mysql_query("SELECT domain_id,redir FROM $md"); $num= mysql_numrows($q); $i=0; while($i<$num){ $red= mysql_result($q, $i, "redir"); $di= mysql_result($q, $i, "domain_id"); $sql= mysql_query("UPDATE $mt SET domain_id='$di' WHERE redir='$red'"); ++$i; } ?> PM me if it works properly. regards