这里就是我有这么远(工作正在进行中)工作:MYSQL根据所选数据库插入一个ID?
INSERT INTO customer_bi.flight_search (
SELECT
NULL,
count(temp.audit_id) AS `count`,
temp.destination,
temp.audit_subsite_id,
temp.subsite_desc,
DATE_FORMAT(temp.audit_date, '%Y-%m-%d') AS search_date
FROM
(
SELECT DISTINCT
a.audit_id,
fs.destination,
a.audit_subsite_id,
s.subsite_desc,
a.audit_date
FROM
audit_flight_search fs
INNER JOIN audit a ON a.audit_id = fs.audit_id
INNER JOIN gns.subsite s ON a.audit_subsite_id = s.subsite_id
WHERE
a.audit_date >= CURRENT_DATE() - INTERVAL 1 DAY
AND a.audit_date < CURRENT_DATE()
AND fs.flight_type = 'ROUNDTRIP'
and (a.audit_member_id IS NULL OR a.audit_member_id != 10172424)
) temp
GROUP BY
temp.subsite_desc,
temp.destination
ORDER BY
temp.subsite_desc ASC,
`count` DESC
)
在数据库customer_bi,我必须列出所有我们的其他数据库的使用标识的表。例如,GNS的ID为4.我想要做的是根据数据库名称在第二个内部联接中插入该标识(本例中为gns.subsite)。我搜索了一直没有找到答案,但我并不真正了解PHP,因此我无法将其用作解决方案。有任何想法吗?