How to use 'select ' in MySQL 'insert' statement
INSERT INTO a.grades (rollno, grade)
SELECT rollno, 'A' FROM b.students WHERE ssn = 12345;
Some DBMS would accept the following, with an extra set of parenthesis around the SELECT statement:
INSERT INTO a.grades (rollno, grade)
VALUES((SELECT rollno FROM b.students WHERE ssn = 12345), 'A');
Columns in insert into and select must be equal
INSERT INTO grades (field1, field2)
SELECT field1, field2 from students where ssn=12345;