Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/php
- <?php
- $mysql = new mysqli( 'localhost', 'xxx', 'xxx','xxx');
- if (mysqli_connect_errno())
- {
- printf("Connect failed: %s\n", mysqli_connect_error());
- exit();
- }
- $sql = 'UPDATE
- cities
- INNER JOIN
- locations
- ON
- locations.city = cities.name
- INNER JOIN
- states
- ON
- states.id = cities.state_id
- AND
- states.abbr = locations.state
- SET
- cities.active = 1
- WHERE
- locations.active = 1';
- $mysql->query( $sql );
- $sql = 'UPDATE
- cities
- INNER JOIN
- locations
- ON
- locations.city = cities.name
- INNER JOIN
- states
- ON
- states.id = cities.state_id
- AND
- states.abbr = locations.state
- SET
- cities.active = 0
- WHERE
- locations.active = 0';
- $mysql->query( $sql );
- $sql = '';
- $sql = 'UPDATE states SET active = 1 WHERE id IN (SELECT DISTINCT state_id FROM cities WHERE active = 1)';
- $mysql->query( $sql );
- $mysql->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement