Search code examples
sqlinsertinner-join

insert into a table from another table with different columns


I have two tables A and B, so that B ⊂ A (it means every column of B is in A, but A has more columns that there is not in B)

Table A is empty and I want to insert the Values of B into A. how can I do that?

for Example: A:
enter image description here

B:
enter image description here


Solution

  • This should work I think

    INSERT INTO A (load, Roll, dest)
    SELECT load, Roll, dest
    FROM B