How to populate a junction table from two tables with a query

I'm wondering if it is possible to populate a junction table with a SQL query from two already populate tables. For Example;


id | name | price
1  |   Foo    |   0
2  |   Bar    |   0
3  |   Tmp  |   0


id | name
1  | Bundle

The above two tables are already populated. Is there a SQL query that would enable me to populate the table below as shown.

Package Products

id | package_id | product_id
1     1                     1
2     1                     2
3     1                     3

Thanks in advance.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewIT / Software Engineering ConsultantCommented:
Is there any relation between the existing two tables, it doesn't appear so?

JakehallasAuthor Commented:
No, unfortunately not. I'm currently migrating the data into a new schema so the relation between these two tables would be the table package_products which is of course the problem I am currently facing. There is also no relation between them from the old schema I am migrating from.
Bill PrewIT / Software Engineering ConsultantCommented:
Well, to product the results you showed, you can do:

SELECT Packages.ID, Products.ID FROM Products, Packages;

Open in new window

Samples test here:

EE29066805, Sql Server - rextester


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JakehallasAuthor Commented:
Amazing! Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.