Advertisement
webpagefxjared

Untitled

Jun 29th, 2011
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #!/usr/bin/php
  2. <?php
  3. $mysql = new mysqli( 'localhost', 'xxx', 'xxx','xxx');
  4. if (mysqli_connect_errno())
  5. {
  6. printf("Connect failed: %s\n", mysqli_connect_error());
  7. exit();
  8. }
  9.  
  10. $sql = 'UPDATE
  11. cities
  12. INNER JOIN
  13. locations
  14. ON
  15. locations.city = cities.name
  16. INNER JOIN
  17. states
  18. ON
  19. states.id = cities.state_id
  20. AND
  21. states.abbr = locations.state
  22. SET
  23. cities.active = 1
  24. WHERE
  25. locations.active = 1';
  26.  
  27.  
  28. $mysql->query( $sql );
  29.  
  30. $sql = 'UPDATE
  31. cities
  32. INNER JOIN
  33. locations
  34. ON
  35. locations.city = cities.name
  36. INNER JOIN
  37. states
  38. ON
  39. states.id = cities.state_id
  40. AND
  41. states.abbr = locations.state
  42. SET
  43. cities.active = 0
  44. WHERE
  45. locations.active = 0';
  46.  
  47. $mysql->query( $sql );
  48.  
  49. $sql = '';
  50.  
  51. $sql = 'UPDATE states SET active = 1 WHERE id IN (SELECT DISTINCT state_id FROM cities WHERE active = 1)';
  52.  
  53. $mysql->query( $sql );
  54.  
  55. $mysql->close();
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement