Home > database >  Please help, about the SQL query a day
Please help, about the SQL query a day

Time:09-22

:
Assuming that I now have a list, there are two fields: name, create_time
Then I have a camera now, when someone walking on cameras will be according to the time in the table to insert a data
requirement:
Given a time period, such as: the 2019-02-01 to 2019-02-01
Is there any way to direct a SQL query from this time period there every day?

CodePudding user response:

I'm a primal want to bad...

CodePudding user response:

Without you, without testing, don't know this line not line,
The SET @ the begin:='2019-02-01';
The SET @ end:='2019-02-07';
SELECT t.n ame FROM table1 t WHERE DATE_FORMAT (tc reate_time, 'Y - m - % d % %) BETWEEN DATE_FORMAT (@ the begin,' Y - m - % d % %) AND DATE_FORMAT (@ the end, 'Y - m - % d % %')
GROUP BY t.n ame, DATE_FORMAT (tc reate_time, 'Y - m - % d % %) HAVING a COUNT (0)=DATEDIFF (@ end, @ the begin) + 1;

CodePudding user response:

refer to the second floor AHUA1001 response:
data without you, without testing, don't know this line not line,
The SET @ the begin:='2019-02-01';
The SET @ end:='2019-02-07';
SELECT t.n ame FROM table1 t WHERE DATE_FORMAT (tc reate_time, 'Y - m - % d % %) BETWEEN DATE_FORMAT (@ the begin,' Y - m - % d % %) AND DATE_FORMAT (@ the end, 'Y - m - % d % %')
GROUP BY t.n ame, DATE_FORMAT (tc reate_time, 'Y - m - % d % %) HAVING a COUNT (0)=DATEDIFF (@ end, @ the begin) + 1;


As if no

CodePudding user response:

refer to the second floor AHUA1001 response:
data without you, without testing, don't know this line not line,
The SET @ the begin:='2019-02-01';
The SET @ end:='2019-02-07';
SELECT t.n ame FROM table1 t WHERE DATE_FORMAT (tc reate_time, 'Y - m - % d % %) BETWEEN DATE_FORMAT (@ the begin,' Y - m - % d % %) AND DATE_FORMAT (@ the end, 'Y - m - % d % %')
GROUP BY t.n ame, DATE_FORMAT (tc reate_time, 'Y - m - % d % %) HAVING a COUNT (0)=DATEDIFF (@ end, @ the begin) + 1;



Data about is the fact that the red box, that is what I said above two fields, such as' 2018-10-13 00:00:00 'now I want to' the 2018-10-15 23:00:00 'should be how to write,,, I quick collapse??

CodePudding user response:

refer to the second floor AHUA1001 response:
data without you, without testing, don't know this line not line,
The SET @ the begin:='2019-02-01';
The SET @ end:='2019-02-07';
SELECT t.n ame FROM table1 t WHERE DATE_FORMAT (tc reate_time, 'Y - m - % d % %) BETWEEN DATE_FORMAT (@ the begin,' Y - m - % d % %) AND DATE_FORMAT (@ the end, 'Y - m - % d % %')
GROUP BY t.n ame, DATE_FORMAT (tc reate_time, 'Y - m - % d % %) HAVING a COUNT (0)=DATEDIFF (@ end, @ the begin) + 1;


I according to what you said is so write:
 SELECT 
P.N AME,
T.p hoto AS cardImage,
Associates. The location,
Associates. Pass_time,
Associates. Full_image
The FROM
Pedestrian associates
The JOIN person_basic_info p ON p.f ace_id=associates. Face_id
On the JOIN person_card_feature t t.i d=p.i d
Where associates. Pass_time BETWEEN '2018-10-13 00:00:00' AND 'the 2018-10-15 23:00:00'
AND associates. Location='1'
Group by p.n ame, associates. Pass_time HAVING COUNT (0)=DATEDIFF (' 2018-10-13 00:00:00 ', '2018-10-15 23:00:00) + 1;

CodePudding user response:

Well, also associated with other tables,
Talk about after you modify, which is not right,
Or put the execution result to also go,
You said no SQL query results,

CodePudding user response:

refer to the second floor AHUA1001 response:
data without you, without testing, don't know this line not line,
The SET @ the begin:='2019-02-01';
The SET @ end:='2019-02-07';
SELECT t.n ame FROM table1 t WHERE DATE_FORMAT (tc reate_time, 'Y - m - % d % %) BETWEEN DATE_FORMAT (@ the begin,' Y - m - % d % %) AND DATE_FORMAT (@ the end, 'Y - m - % d % %')
GROUP BY t.n ame, DATE_FORMAT (tc reate_time, 'Y - m - % d % %) HAVING a COUNT (0)=DATEDIFF (@ end, @ the begin) + 1;

I made, the group by remove the time is ok, but the SQL, or have questions, because demand must be there every day, but twice in the SQL as long as the same day, and can not to come out the same, the next day,

CodePudding user response:

Try this
The SET @ the begin:='2019-02-01';
The SET @ end:='2019-02-07';
SELECT t.n ame FROM table1 t WHERE DATE_FORMAT (tc reate_time, 'Y - m - % d % %) BETWEEN DATE_FORMAT (@ the begin,' Y - m - % d % %) AND DATE_FORMAT (@ the end, 'Y - m - % d % %')
GROUP BY t.n ame, DATE_FORMAT (tc reate_time, 'Y - m - % d % %) HAVING a COUNT (DISTINCT DATE_FORMAT (tc reate_time,' Y - m - % d % %))=DATEDIFF (@ end, @ the begin) + 1;

CodePudding user response:

The
reference 3 floor AHUA1001 response:
try this
The SET @ the begin:='2019-02-01';
The SET @ end:='2019-02-07';
SELECT t.n ame FROM table1 t WHERE DATE_FORMAT (tc reate_time, 'Y - m - % d % %) BETWEEN DATE_FORMAT (@ the begin,' Y - m - % d % %) AND DATE_FORMAT (@ the end, 'Y - m - % d % %')
GROUP BY t.n ame, DATE_FORMAT (tc reate_time, 'Y - m - % d % %) HAVING a COUNT (DISTINCT DATE_FORMAT (tc reate_time,' Y - m - % d % %))=DATEDIFF (@ end, @ the begin) + 1;


Sometimes that if the minutes...

CodePudding user response:

refer to the eighth floor AHUA1001 response:
try this
The SET @ the begin:='2019-02-01';
The SET @ end:='2019-02-07';
SELECT t.n ame FROM table1 t WHERE DATE_FORMAT (tc reate_time, 'Y - m - % d % %) BETWEEN DATE_FORMAT (@ the begin,' Y - m - % d % %) AND DATE_FORMAT (@ the end, 'Y - m - % d % %')
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related