MySql - How to insert data from another table? [closed]












-1















This is the scheme I am working on:



image
, 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?










share|improve this 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 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
















-1















This is the scheme I am working on:



image
, 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?










share|improve this 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 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














-1












-1








-1








This is the scheme I am working on:



image
, 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?










share|improve this question
















This is the scheme I am working on:



image
, 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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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














  • 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








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












1 Answer
1






active

oldest

votes


















2














INSERT INTO table2 (column1, column2, column3)
SELECT column1, column2, column3
FROM table1
WHERE condition;


is that you asking or what?






share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    INSERT INTO table2 (column1, column2, column3)
    SELECT column1, column2, column3
    FROM table1
    WHERE condition;


    is that you asking or what?






    share|improve this answer




























      2














      INSERT INTO table2 (column1, column2, column3)
      SELECT column1, column2, column3
      FROM table1
      WHERE condition;


      is that you asking or what?






      share|improve this answer


























        2












        2








        2







        INSERT INTO table2 (column1, column2, column3)
        SELECT column1, column2, column3
        FROM table1
        WHERE condition;


        is that you asking or what?






        share|improve this answer













        INSERT INTO table2 (column1, column2, column3)
        SELECT column1, column2, column3
        FROM table1
        WHERE condition;


        is that you asking or what?







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 26 '18 at 6:48









        Jayanta BaishyaJayanta Baishya

        448




        448

















            Popular posts from this blog

            Costa Masnaga

            Fotorealismo

            Sidney Franklin