Click here to Skip to main content
16,019,263 members
Home / Discussions / Database
   

Database

 
QuestionGetting data Pin
Member 1302296325-Feb-17 0:23
Member 1302296325-Feb-17 0:23 
AnswerRe: Getting data Pin
Richard MacCutchan25-Feb-17 20:48
mveRichard MacCutchan25-Feb-17 20:48 
Questionc# to call MySQL Update Stored Proc error Pin
jonmy24-Feb-17 0:00
jonmy24-Feb-17 0:00 
AnswerRe: c# to call MySQL Update Stored Proc error Pin
Richard Deeming24-Feb-17 0:26
mveRichard Deeming24-Feb-17 0:26 
GeneralRe: c# to call MySQL Update Stored Proc error Pin
jonmy24-Feb-17 0:37
jonmy24-Feb-17 0:37 
QuestionSave a Query as a View issue Pin
john_berman21-Feb-17 11:35
john_berman21-Feb-17 11:35 
AnswerRe: Save a Query as a View issue Pin
Richard Deeming21-Feb-17 12:04
mveRichard Deeming21-Feb-17 12:04 
QuestionTime Variance Query works - Sorry it needs a tweak Pin
john_berman21-Feb-17 9:48
john_berman21-Feb-17 9:48 
So this query now works really well

SELECT DISTINCT
b.event_id AS a,
b.user_ID AS a,
b.date AS a,
b.Time AS a
FROM quadrantids2017 AS a
JOIN quadrantids2017 AS b
WHERE a.`date` = b.`date`

AND a.user_ID != b.user_ID
AND time_to_sec(a.`Time`) - time_to_sec(b.`Time`) BETWEEN -30 AND 30

ORDER BY
a.date ASC,
a.Time ASC,
a.user_ID ASC


I have two issues

1 - Its slow, there are 3144 records and its taking 37 seconds to get the result which is 1519 records so I added an index to event,_id, user_id, date and time and its reduced to 24 secs

2 -

It returns the results like this

33501 1 2017-01-01 01:14:59
47829 3 2017-01-01 01:24:49
33503 1 2017-01-01 01:24:48
37787 2 2017-01-01 02:21:13
33504 1 2017-01-01 02:20:43
47837 3 2017-01-01 03:06:19
33505 1 2017-01-01 03:06:17
47838 3 2017-01-01 03:07:30
33506 1 2017-01-01 03:07:28
33507 1 2017-01-01 03:07:42
47840 3 2017-01-01 04:35:12
33510 1 2017-01-01 04:35:11

Im wondering how I might show the related results

ie


47829 3 2017-01-01 01:24:49
33503 1 2017-01-01 01:24:48

37787 2 2017-01-01 02:21:13
33504 1 2017-01-01 02:20:43

47837 3 2017-01-01 03:06:19
33505 1 2017-01-01 03:06:17

47838 3 2017-01-01 03:07:30
33506 1 2017-01-01 03:07:28
33507 1 2017-01-01 03:07:42

47840 3 2017-01-01 04:35:12
33510 1 2017-01-01 04:35:11

Is there any way I can add a group number to each record or something like that ?

John B
QuestionMySql Resource Pin
BobbyStrain20-Feb-17 14:12
BobbyStrain20-Feb-17 14:12 
AnswerRe: MySql Resource Pin
Peter Leow20-Feb-17 16:08
professionalPeter Leow20-Feb-17 16:08 
QuestionTricky Query that includes a time difference Pin
john_berman20-Feb-17 6:09
john_berman20-Feb-17 6:09 
AnswerRe: Tricky Query that includes a time difference Pin
Richard MacCutchan20-Feb-17 6:22
mveRichard MacCutchan20-Feb-17 6:22 
GeneralRe: Tricky Query that includes a time difference Pin
john_berman20-Feb-17 6:45
john_berman20-Feb-17 6:45 
GeneralRe: Tricky Query that includes a time difference Pin
Richard Deeming20-Feb-17 6:52
mveRichard Deeming20-Feb-17 6:52 
GeneralRe: Tricky Query that includes a time difference Pin
john_berman20-Feb-17 7:04
john_berman20-Feb-17 7:04 
GeneralRe: Tricky Query that includes a time difference Pin
john_berman20-Feb-17 7:06
john_berman20-Feb-17 7:06 
QuestionDatabase Design - Help Appreciated Pin
john_berman19-Feb-17 21:03
john_berman19-Feb-17 21:03 
AnswerRe: Database Design - Help Appreciated Pin
Mycroft Holmes19-Feb-17 21:38
professionalMycroft Holmes19-Feb-17 21:38 
GeneralRe: Database Design - Help Appreciated Pin
john_berman20-Feb-17 6:07
john_berman20-Feb-17 6:07 
QuestionDB Case Sensitivity, unexpected/surprising behaviour Pin
User 1106097918-Feb-17 1:17
User 1106097918-Feb-17 1:17 
AnswerRe: DB Case Sensitivity, unexpected/surprising behaviour Pin
Richard Deeming18-Feb-17 1:35
mveRichard Deeming18-Feb-17 1:35 
PraiseRe: DB Case Sensitivity, unexpected/surprising behaviour Pin
User 1106097918-Feb-17 1:40
User 1106097918-Feb-17 1:40 
GeneralRe: DB Case Sensitivity, unexpected/surprising behaviour Pin
User 1106097918-Feb-17 3:49
User 1106097918-Feb-17 3:49 
GeneralRe: DB Case Sensitivity, unexpected/surprising behaviour Pin
Richard Deeming18-Feb-17 8:30
mveRichard Deeming18-Feb-17 8:30 
GeneralRe: DB Case Sensitivity, unexpected/surprising behaviour Pin
User 1106097918-Feb-17 8:35
User 1106097918-Feb-17 8:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.