Reputation: 521
I have a TableA from where I would like some information for e.g. tableA has columns **name, age and rollNo**
and I would like to insert **age**
and **rollNo**
from tableA to tableB wherever the age is greater than 20 and rollNo less than 500
Is there anyway this can be done in MySQL using a procedure or something.
Upvotes: 1
Views: 935
Reputation: 107518
This can be done in a single query using the INSERT ... SELECT
syntax:
INSERT INTO TableB (Age, RollNo)
SELECT Age, RollNo
FROM TableA
WHERE Age > 20 AND RollNo < 500
Upvotes: 2