0

I have this table which is used to generate second table with the result:

SELECT
        COUNT(*) count,
        SUM(amount) volume,
        DATE(created_at) date,
        DAY(created_at) day,
        type transaction_type
        status
        FROM payment_transactions
        WHERE created_at BETWEEN '2018-11-11' AND '2018-11-14'   

Example result:

count volume  date  status 
1 3000  2018-11-11  approved 
1 3000  2018-11-11  approved 

The question is how to insert this result into second table with one query? Probably with batch insert for MariaDB?

Is there a way to archive this with one SQL query?

  • 3
    INSERT INTO...SELECT – McNets Feb 7 at 9:15
  • Your proposal it to insert the result into DB table? – Peter Penzov Feb 7 at 9:21
  • Is this the question?: how to insert this result into second table with one query? – McNets Feb 7 at 9:24
  • Yes. Can you please paster official answer so I can rate it? – Peter Penzov Feb 7 at 9:27
  • 1
    So, @PeterPenzov, when you google "mysql insert select" it's the very first hit. Please do some research before asking questions. – tombom Feb 7 at 9:47

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.