MySql - How to insert data from another table? [closed]
This is the scheme I am working on:
, I'm trying to insert data to takes
table in the following condition:
if there's a student whose studied at 2015, semester=2, grade<80 then insert (on a new record) his student id, course id, year=2015, semester=3
I've tried several ways to do it but couldn't succeed
How am I supposed to do that?
mysql
closed as too broad by Tim Biegeleisen, Madhur Bhaiya, Suraj Rao, tripleee, AdrianHHH Nov 26 '18 at 10:04
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
This is the scheme I am working on:
, I'm trying to insert data to takes
table in the following condition:
if there's a student whose studied at 2015, semester=2, grade<80 then insert (on a new record) his student id, course id, year=2015, semester=3
I've tried several ways to do it but couldn't succeed
How am I supposed to do that?
mysql
closed as too broad by Tim Biegeleisen, Madhur Bhaiya, Suraj Rao, tripleee, AdrianHHH Nov 26 '18 at 10:04
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
1
You can useINSERT INTO.. SELECT
. Refer: dev.mysql.com/doc/refman/8.0/en/insert-select.html Try something, and share the latest code attempt of yours to the question; so that we can put you in the right direction.
– Madhur Bhaiya
Nov 26 '18 at 6:48
What you've tried so far? Please post code.
– Bhoomi patel
Nov 26 '18 at 6:51
What value gets inserted for the grade? Voting to close as unclear what you are asking. You should at least take 5 minutes to invest in your question, and add sample data.
– Tim Biegeleisen
Nov 26 '18 at 6:51
add a comment |
This is the scheme I am working on:
, I'm trying to insert data to takes
table in the following condition:
if there's a student whose studied at 2015, semester=2, grade<80 then insert (on a new record) his student id, course id, year=2015, semester=3
I've tried several ways to do it but couldn't succeed
How am I supposed to do that?
mysql
This is the scheme I am working on:
, I'm trying to insert data to takes
table in the following condition:
if there's a student whose studied at 2015, semester=2, grade<80 then insert (on a new record) his student id, course id, year=2015, semester=3
I've tried several ways to do it but couldn't succeed
How am I supposed to do that?
mysql
mysql
edited Nov 26 '18 at 6:55
Suraj Rao
23.9k85972
23.9k85972
asked Nov 26 '18 at 6:44
SnirSnir
11
11
closed as too broad by Tim Biegeleisen, Madhur Bhaiya, Suraj Rao, tripleee, AdrianHHH Nov 26 '18 at 10:04
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as too broad by Tim Biegeleisen, Madhur Bhaiya, Suraj Rao, tripleee, AdrianHHH Nov 26 '18 at 10:04
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
1
You can useINSERT INTO.. SELECT
. Refer: dev.mysql.com/doc/refman/8.0/en/insert-select.html Try something, and share the latest code attempt of yours to the question; so that we can put you in the right direction.
– Madhur Bhaiya
Nov 26 '18 at 6:48
What you've tried so far? Please post code.
– Bhoomi patel
Nov 26 '18 at 6:51
What value gets inserted for the grade? Voting to close as unclear what you are asking. You should at least take 5 minutes to invest in your question, and add sample data.
– Tim Biegeleisen
Nov 26 '18 at 6:51
add a comment |
1
You can useINSERT INTO.. SELECT
. Refer: dev.mysql.com/doc/refman/8.0/en/insert-select.html Try something, and share the latest code attempt of yours to the question; so that we can put you in the right direction.
– Madhur Bhaiya
Nov 26 '18 at 6:48
What you've tried so far? Please post code.
– Bhoomi patel
Nov 26 '18 at 6:51
What value gets inserted for the grade? Voting to close as unclear what you are asking. You should at least take 5 minutes to invest in your question, and add sample data.
– Tim Biegeleisen
Nov 26 '18 at 6:51
1
1
You can use
INSERT INTO.. SELECT
. Refer: dev.mysql.com/doc/refman/8.0/en/insert-select.html Try something, and share the latest code attempt of yours to the question; so that we can put you in the right direction.– Madhur Bhaiya
Nov 26 '18 at 6:48
You can use
INSERT INTO.. SELECT
. Refer: dev.mysql.com/doc/refman/8.0/en/insert-select.html Try something, and share the latest code attempt of yours to the question; so that we can put you in the right direction.– Madhur Bhaiya
Nov 26 '18 at 6:48
What you've tried so far? Please post code.
– Bhoomi patel
Nov 26 '18 at 6:51
What you've tried so far? Please post code.
– Bhoomi patel
Nov 26 '18 at 6:51
What value gets inserted for the grade? Voting to close as unclear what you are asking. You should at least take 5 minutes to invest in your question, and add sample data.
– Tim Biegeleisen
Nov 26 '18 at 6:51
What value gets inserted for the grade? Voting to close as unclear what you are asking. You should at least take 5 minutes to invest in your question, and add sample data.
– Tim Biegeleisen
Nov 26 '18 at 6:51
add a comment |
1 Answer
1
active
oldest
votes
INSERT INTO table2 (column1, column2, column3)
SELECT column1, column2, column3
FROM table1
WHERE condition;
is that you asking or what?
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
INSERT INTO table2 (column1, column2, column3)
SELECT column1, column2, column3
FROM table1
WHERE condition;
is that you asking or what?
add a comment |
INSERT INTO table2 (column1, column2, column3)
SELECT column1, column2, column3
FROM table1
WHERE condition;
is that you asking or what?
add a comment |
INSERT INTO table2 (column1, column2, column3)
SELECT column1, column2, column3
FROM table1
WHERE condition;
is that you asking or what?
INSERT INTO table2 (column1, column2, column3)
SELECT column1, column2, column3
FROM table1
WHERE condition;
is that you asking or what?
answered Nov 26 '18 at 6:48
Jayanta BaishyaJayanta Baishya
448
448
add a comment |
add a comment |
1
You can use
INSERT INTO.. SELECT
. Refer: dev.mysql.com/doc/refman/8.0/en/insert-select.html Try something, and share the latest code attempt of yours to the question; so that we can put you in the right direction.– Madhur Bhaiya
Nov 26 '18 at 6:48
What you've tried so far? Please post code.
– Bhoomi patel
Nov 26 '18 at 6:51
What value gets inserted for the grade? Voting to close as unclear what you are asking. You should at least take 5 minutes to invest in your question, and add sample data.
– Tim Biegeleisen
Nov 26 '18 at 6:51