Reputation: 143
I've got an insert query that contains several select statements. I feel like there's got to be a better (more efficient, more optimized, etc) way to do this. Any suggestions?
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"))
Upvotes: 1
Views: 36
Reputation: 8584
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"
Upvotes: 4