Users can have more than 1 account in 2 different tables. I'm trying to check if any of their accounts has previously ran the script in the past 25mins. Here is my code:
$cehcksql = '
SELECT account
FROM database_data.users2
WHERE time >= DATE_SUB(NOW(), INTERVAL 25 MINUTE)
AND account IN (
SELECT account
FROM database_data.users2
WHERE ip = (SELECT ip FROM database_data.users2 WHERE account="$subid")
)
UNION
SELECT account
FROM database_data.users
WHERE time >= DATE_SUB(NOW(), INTERVAL 25 MINUTE)
AND account IN (
SELECT account
FROM database_data.users
WHERE ip = (SELECT ip FROM database_data.users WHERE account="$subid")
)
';
$cehcksql_result = mysql_query($cehcksql);
$num_rows_fetched_fr_check = mysql_num_rows($cehcksql_result);
if($num_rows_fetched_fr_check==0){
But the problem is it's treating each table individually. e.g. if a user has more than 1 account in the same table it will check that and work ok but if an account in the other table has ran the script in the past 25mins it wont register it and will run the script regardless. Any help will be great!