0

Say there are 2 tables with:

no key ref to each other
different number of rows

table1:
id   item
a    Apple
b    Pear

table2
no   student
I    John
II   Sara
III  Pete

Is it possible to combine:

SELECT item FROM table1
SELECT student FROM table2

Then PHP output table3 like this?

table3
ITEM       Student
Apple      John
Pear       Sara
           Pete 

ITEM and Student are totally independent of each other. I just want to list them side by side. (Which means ITEM that same row with Pete will have no value). Need some expert view. Thanks.

P. Lau
  • 165
  • 1
  • 11

1 Answers1

0

try

create table table3 as select item from table1; 
alter table table3 add column student TEXT;
update table3 set student = (select student from table2);
  • Also, use this solution, I think it explains what you want to do. https://stackoverflow.com/questions/1198124/combine-two-tables-that-have-no-common-fields – twoheadedmona Dec 07 '17 at 15:12