programmerJavaPL programmerJavaPL - 1 year ago 105
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.

Answer Source

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"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download