Save a Query as a View issue
-
How can I convert this query to a view The query work but i get error message if I try to save as a view - the errors talk about duplicate names ?
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 30Thanks in advance John B
-
How can I convert this query to a view The query work but i get error message if I try to save as a view - the errors talk about duplicate names ?
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 30Thanks in advance John B
Every column in a view needs to have a unique name. You've given all four columns the alias "a", which is obviously not unique. Just remove the four
As a
alias from theSELECT
part of the query, and you should be able to create a view.SELECT DISTINCT
b.event_id,
b.user_ID,
b.date,
b.Time
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 30Alternatively, give each column a unique alias.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer