So i have two table
Detail table
Name - Admno - ModuleCode - PASS
John , 127261, 87772, -
candy , 923823, 2323, -
result table
Admno - ModuleCode - PASS
127261, 87772,Yes
923823, 2323,No
Notice that result table don't have name whereas detail table have and detail table.PASS was not been filled .What i was trying is to fill Detail table column 'PASS' from result table column 'PASS' WHERE both detail.admno = result.admno AND detail.ModuleCode = result.ModuleCode
INSERT into detail SET detail.PASS= `result`.PASS FROM
`result`, detail WHERE `result`.Admno = detail.Admno
AND `result`.Code = detail.ModuleCode
but the error i got was Error code 1064, SQL state 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' FROM
result
, detail WHERE result
.Admno = detail.Admno AND result
.Code = ' at line 1 Line 1, column 1
By the way I'm using java in netbean to do sql statement.
You'll need to have a join statement to combine data from multiple tables. Below is likely what you're looking for.
UPDATE detail INNER JOIN `result` ON `result`.Admno = detail.Admno
AND `result`.Code = detail.ModuleCode SET detail.PASS=`result`.PASS
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.