我无法弄清楚如何对该查询进行内部左联接更新(这是选择查询有效):
SELECT
*
FROM
emr AS e
LEFT JOIN visit_ltnot AS v ON e.guid = v._pn
WHERE
closedate='12-31-79' AND pat='00000906' AND apptstatus=''
AND v.pdate='' AND emrdate <= '2013-11-26';
我需要更新emr表上的Closedate。
我绑定了以下查询:
UPDATE emr
FROM
emr AS e
LEFT JOIN visit_ltnot AS v ON e.guid = v._pn SET closedate=''
WHERE
closedate='12-31-79' AND pat='00000906' AND apptstatus=''
AND v.pdate='' AND emrdate <= '2013-11-26';
UPDATE emr
SET closedate=''
FROM
emr AS e
LEFT JOIN visit_ltnot AS v ON e.guid = v._pn
WHERE
closedate='12-31-79' AND pat='00000906' AND apptstatus=''
AND v.pdate='' AND emrdate <= '2013-11-26';
我遇到语法错误,我需要更新closedate值。
答案 0 :(得分:1)
如果您使用的是MySQL,则应该可以使用:
didUpdate
注意:
UPDATE emr e LEFT JOIN
visit_ltnot v
ON e.guid = v._pn
SET closedate = ''
WHERE closedate = '12-31-79' AND
pat = '00000906' AND
apptstatus = '' AND
v.pdate = '' AND
emrdate <= '2013-11-26';
在MySQL中没有UPDATE
子句。FROM
正在将外部联接变为内部联接。因此,您不妨使用v.pdate
。inner join
之类的日期格式。正确的日期格式为'12-31-79'
。'1979-12-31'
没有意义。