我已将最后三个字段添加到此表中,但它们都是空白的。所有记录都填写了前三个。表定义是,
的MySQL>描述nh3tk;
+-----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+-------------+------+-----+---------+-------+
| spectra | varchar(50) | NO | PRI | NULL | |
| value | float | NO | | NULL | |
| error | float | NO | | NULL | |
| nonthermal_FWHM | double | YES | | NULL | |
| sound_speed | double | YES | | NULL | |
+-----------------+-------------+------+-----+---------+-------+
选择查询,有效,是
select nh3tk.spectra,
pow((pow(2.35*nh3lw.sd_lw,2)-1.38065e-23*8*ln(2)*nh3tk.value/2.82e-26),0.5) as nonthermal_FWHM,
pow(1.38065e-23*nh3tk.value/(2.33*3.348e-27),0.5) as sound_speed
from nh3tk
left join nh3lw on nh3tk.spectra=nh3lw.spectra;
现在我只需要从该查询中取出两个计算字段,并将它们放在nh3tk的正确字段中,其中光谱匹配。
感谢任何帮助。
祝你好运 詹姆斯
答案 0 :(得分:2)
UPDATE nh3tk
JOIN nh3lw
ON nh3lw.spectra = nh3tk.spectra
SET nonthermal_FWHM = pow((pow(2.35*nh3lw.sd_lw,2)-1.38065e-23*8*ln(2)*nh3tk.value/2.82e-26),0.5),
sound_speed = pow(1.38065e-23*nh3tk.value/(2.33*3.348e-27),0.5)
不确定error
,因为您未在查询中选择它。
答案 1 :(得分:0)
我最终用这个来完成这项任务,
UPDATE nh3tk
LEFT JOIN nh3lw ON nh3lw.spectra = nh3tk.spectra
SET nonthermal_FWHM = pow((pow(2.35*nh3lw.sd_lw,2)-1.38065e-23*8*ln(2)*nh3tk.value/2.82e-26),0.5),
sound_speed = pow(1.38065e-23*nh3tk.value/(2.33*3.348e-27),0.5);
感谢所有人的回答,并花时间看看这个, 詹姆斯