MySQL - Combining INSERT, VALUES, and SELECT?
Makes sense and is called INSERT SELECT. This is an example query for the uniqueDeviceId 123, Score 5 and Difficulty 'easy':
INSERT INTO scores (score, difficulty, playerid) SELECT 5, 'easy', id FROM player WHERE uniqueDeviceId = 123;
What about this approach:
INSERT INTO `tableA` SET columnA = (SELECT `columnY` FROM `tableY` WHERE `id` = 2), columnB = (SELECT `columnZ` FROM `tableB` WHERE `id` = 3);
I didn't benchmarked it yet. But using multiple SELECT
statements will burden the Database server. The plus side of this approach is the readability.