remedy remedy - 1 year ago 118
MySQL Question

Syntax error with SQL associative entity

I have no idea why this code won't work. Throws syntax error, but from my knowledge this should work. Can someone explain to me what I'm doing wrong.

insert into playerteam(playerId, teamId) select id from player where
player.firstname='John' and select id from team where team.`name`='Swim Team';

Answer Source

Use as given below:

INSERT INTO playerteam(playerId, teamId) 
SELECT (SELECT id FROM player WHERE player.firstname='John'), 
    (SELECT id FROM team WHERE team.`name`='Swim Team');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download