Select values that meet different conditions on different rows?

Ok, I got downvoted on this so I decided to test it: CREATE TABLE userrole ( userid INT, roleid INT, PRIMARY KEY (userid, roleid) ); CREATE INDEX ON userrole (roleid); Run this: <?php ini_set(‘max_execution_time’, 120); // takes over a minute to insert 500k+ records $start = microtime(true); echo “<pre>\n”; mysql_connect(‘localhost’, ‘scratch’, ‘scratch’); if (mysql_error()) { … Read more