Arpan Dang
Arpan Dang

Reputation: 21

Create a table from 2 different tables

Given the following two tables:

  1. Products with columns p_id and name
  2. Users with columns u_id and password

I want to create a 3rd table named review, which will have the following 3 columns: p_id, u_id, review. The p_id and u_id are taken from products and users table respectively, and would kind of create a Cartesian product of the above two tables with added third column to it. How can I do that?

Upvotes: 0

Views: 85

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133400

You can create with select

create table3 (p_id int(1), u_id int(11), review varchar(64)); 
insert table3 select Products.p_id, Users.u_id, 'value_for_review'
from Products, Users 

Upvotes: 2

Related Questions