I have a users table with 450,000 records. The table structure is as so:
UserID Int(11) Primary Key
Firstname (50) Varchar
Lastname (50) Varchar
I also need to check two other table to see if the UserID is in those tables. (the structure is a bit different, but the table have the same UserID) I am running this sub query below, and is running very slow. Appreciate a second set of eyes to offer up a fresh perspective to help run a bit faster...
SELECT
`Users`.`Firstname`,
`Users`.`Lastname`,
`Users`.`UserID`
FROM `Users`
WHERE `Users`.`UserID` IN (SELECT `admin`.`UserID` FROM `admin` WHERE `admin`.`UserID`=`User`.`UserID`)
AND `Users`.`UserID` IN (SELECT `elite`.`UserID` FROM `elite` WHERE `elite`.`UserID`=`Users`.`UserID`)
AND `Users`.`Lastname` LIKE '%smith%'
SHOW CREATE TABLE ...for each table, and also postEXPLAIN SELECT ...output.