我有一个包含多个select语句的插入查询。我觉得这样做会更好(更高效,更优化等)。有什么建议?
INSERT INTO log (logtype, subtype, src_ip, dst_ip, dst_port, query) VALUES (2, 1,
(SELECT src_ip FROM query WHERE uid="123"),
(SELECT dst_ip FROM query WHERE uid="123"),
(SELECT dst_port FROM query WHERE uid="123"),
(SELECT query FROM query WHERE uid="123"))
答案 0 :(得分:4)
INSERT INTO log (logtype, subtype, src_ip, dst_ip, dst_port, query)
SELECT 2, 1, src_ip, dst_ip, dst_port, query
FROM query WHERE uid="123"