programmerJavaPL programmerJavaPL - 3 months ago 13
SQL Question

Copying data from the rows of different tables to one line to another

I have such a situation:

enter image description here

enter image description here

enter image description here

The table-third would like to get the value of fcd for "C20 / 25" and fyk for B400C.

The following method works but not what I want:

INSERT INTO Column(fck)
FROM StrengthClassesForConcrete
WHERE nameClass = "C20/25";

INSERT INTO Column(fyk)
FROM StrengthClassesForSteel
WHERE nameClass = "B400C"

enter image description here

I wish they added to one line, and that was always only one row in the table.


It should be like this:

 INSERT INTO Column(fck,fyk) 
     SELECT StrengthClassesForConcrete.fck, StrengthClassesForSteel.fyk 
     FROM   StrengthClassesForConcrete, StrengthClassesForSteel 
     WHERE  StrengthClassesForConcrete.nameClass = "C20/25" 
     AND    StrengthClassesForSteel.nameClass = "B400C"