I´m trying two find user who were active in the same date, I´ve code that runs
select place,date,user, artNumber
from jobs
where user in (
select user2
from userActive
where date between 20180101 and 20181011 and user2 = 'nightJob')
This just give me when nightJob have been active, how can I match so the result return wich other user have been active in the same time as nightJob, I would love an explanation of the sulotion becuse I´m trying to learn.
I sound like amatur and mabye I´m, but can someone explain my code, I´ve wrot e it but I just whant to check if I understand it correctly. I dont whant fixed results, its over hundred users but nightJob is always that specific username.
The following recommendations will help you in your SQL tuning process.
You'll find 3 sections below:
ALTER TABLE `userActive` ADD INDEX `useractive_idx_user2_date` (`user2`,`date`);
SELECT
jobs.place,
jobs.date,
jobs.user,
jobs.artNumber
FROM
jobs
WHERE
EXISTS (
SELECT
1
FROM
userActive
WHERE
(
userActive.date BETWEEN 20180101 AND 20181011
AND userActive.user2 = 'nightJob'
)
AND (
jobs.user = userActive.user2
)
)