UPDATE (SELECT DISTINCT
t.TransientBucketId, t.name
FROM
transientBucket t, phase_iii_transient_catalogue_ssdr3 p
WHERE
t.transientBucketId = p.TransientBucketId
AND name NOT LIKE 'atel_%'
AND name LIKE 'SN2%') t,
phase_iii_transient_catalogue_ssdr3 p
SET
p.TRANSIENT_IAU_ID = t.name
WHERE
t.transientBucketId = p.TransientBucketId
and p.TRANSIENT_IAU_ID is null;
UPDATE (SELECT DISTINCT
t.TransientBucketId, t.name
FROM
transientBucket t, phase_iii_transient_catalogue_ssdr3 p
WHERE
t.transientBucketId = p.TransientBucketId
AND name NOT LIKE 'atel_%'
AND name LIKE 'AT2%') t,
phase_iii_transient_catalogue_ssdr3 p
SET
p.TRANSIENT_IAU_ID = t.name
WHERE
t.transientBucketId = p.TransientBucketId
and p.TRANSIENT_IAU_ID is null;
update (select t.transientBucketID, name, discoveryMJD from (select transientBucketID, min(observationMJD) as discoveryMJD
from transientBucket
where name NOT LIKE 'atel_%'
AND name NOT LIKE 'AT2%'
AND name NOT LIKE 'SN2%'
AND name NOT LIKE '<%'
AND limitingMag = 0
AND observationMJD > 50000
group by transientBucketID) s, transientBucket t
WHERE
t.transientBucketId = s.TransientBucketId
and t.observationMJD = s.discoveryMJD
and name NOT LIKE 'atel_%'
AND name NOT LIKE 'AT2%'
AND name NOT LIKE 'SN2%'
AND name NOT LIKE '<%'
AND magnitude is not null
AND limitingMag = 0
AND observationMJD > 50000 group by transientBucketID) s, phase_iii_transient_catalogue_ssdr3 p
set p.TRANSIENT_DISCOVERY_ID=name
where p.transientBucketId = s.TransientBucketId;
update phase_iii_transient_catalogue_ssdr3 set TRANSIENT_DISCOVERY_ID=TRANSIENT_IAU_ID where TRANSIENT_DISCOVERY_ID is null;
UPDATE phase_iii_transient_catalogue_ssdr3 p,
(SELECT
transientBucketId,
GROUP_CONCAT(name
SEPARATOR ', ') alternative_ids
FROM
(SELECT DISTINCT
t.TransientBucketId, t.name
FROM
transientBucket t, phase_iii_transient_catalogue_ssdr3 p
WHERE
t.transientBucketId = p.TransientBucketId
AND name NOT LIKE 'atel_%'
AND name NOT LIKE 'AT2%'
AND name NOT LIKE 'SN2%'
AND name NOT LIKE '<%'
AND t.observationMJD > 50000
AND name NOT IN (SELECT
TRANSIENT_DISCOVERY_ID
FROM
phase_iii_transient_catalogue_ssdr3)) s
GROUP BY transientBucketId) s
SET
p.TRANSIENT_ALTERNATIVE_IDS = s.alternative_ids
WHERE
p.TransientBucketId = s.TransientBucketId;