我试图在MySQL中创建一个事件来读取" adc1":后面的值并将值写入新列。这个值在一个包含更多信息的单元格内,所以只说WHERE x.y =' 1'不起作用。
我在一次活动中尝试过这样做。但是,当我把1个以上的替换为“替代”时,在一个事件中,它告诉我它是错误的MySQL。我阅读的手册对我没有帮助。
有人可以帮忙吗?
所以这下面没有用。它应该是什么? (' make event'部分必须高于工作。)
REPLACE INTO results(id, updatetime, type)
SELECT devices.id, devices.lastupdate, '1'
FROM devices, positions
WHERE positions.id = devices.positionid
AND positions.attributes
LIKE '%adc1_:1%';
REPLACE INTO results(id, updatetime, type)
SELECT devices.id, devices.lastupdate, '2'
FROM devices, positions
WHERE positions.id = devices.positionid
AND positions.attributes
LIKE '%adc1_:2%';
REPLACE INTO results(id, updatetime, type)
SELECT devices.id, devices.lastupdate, '3'
FROM devices, positions
WHERE positions.id = devices.positionid
AND positions.attributes
LIKE '%adc1_:3%';
REPLACE INTO results(id, updatetime, type)
SELECT devices.id, devices.lastupdate, 'etc'
FROM devices, positions
WHERE positions.id = devices.positionid
AND positions.attributes
LIKE '%adc1_:etc%';