我想用列handleMouseDown = event => {
this.setState({
dragging: true,
dragStart: event.screenX,
});
};
handleMouseUp = () => {
this.setState({ dragging: false });
};
handleMouseMove = event => {
if (this.state.dragging) {
const position = event.screenX;
// <-- update your image index
}
};
render = () => {
return (
<div onMouseDown={this.handleMouseDown}>
{this.renderImage()}
</div>
);
};
componentDidMount = () => {
document.addEventListener('mousemove', this.handleMouseMove, false);
document.addEventListener('mouseup', this.handleMouseUp, false);
};
componentWillUnmount = () => {
document.removeEventListener('mousemove', this.handleMouseMove, false);
document.removeEventListener('mouseup', this.handleMouseUp, false);
};
的值更新列created_at
的值,其中列updated_at
的值是 0000-00-00 。
我尝试了以下查询:
created_at
但是查询结果如下:
UPDATE tbl_message_types a
SET a.created_at = (
SELECT
c.updated_at
FROM
( SELECT b.updated_at
FROM tbl_message_types b
WHERE b.created_at LIKE '%0000-00-00%'
AND a.id = c.id ) AS c
)
AND a.created_at LIKE '%0000-00-00%';
如何修改查询?
答案 0 :(得分:0)
您的别名不适当,但是我会使用连接来表达此更新:
UPDATE tbl_message_types a
INNER JOIN UPDATE tbl_message_types b
ON a.id = b.id AND
COALESCE(b.created_at, '0000-00-00') != '0000-00-00'
WHERE COALESCE(a.created_at, '0000-00-00') = '0000-00-00';
请注意,您不清楚表中的日期时间值如何为0000-00-00
。我会以同样的方式对待NULL
,尽管如果您不同意也可以删除对COALESCE
的呼叫。
答案 1 :(得分:0)
我认为您可以以非常简化的方式来完成此操作。为什么要坚持一个查询..?首先选择,然后更新。试试这个。
select
value1 from tableName
where columnX like '%someThing%' and columnY = 'SomeValue' as value11;
update sametableName set someColumn= value11
where....