Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 是否可以选择下一行';如果条件不匹配,同一列上的单元格值?_Mysql_Join - Fatal编程技术网

Mysql 是否可以选择下一行';如果条件不匹配,同一列上的单元格值?

Mysql 是否可以选择下一行';如果条件不匹配,同一列上的单元格值?,mysql,join,Mysql,Join,我有一个表flaggedcomment和一个表price 在flaggedcomment中,有两个空列Price\u DateTime和Price\u Open,我想从Price复制,具体取决于上的条件。查询如下 UPDATE flaggedcomment as t1 LEFT JOIN price as t2 ON t1.Ticker_Ticker_ID = t2.Ticker_Ticker_ID AND t1.Comment_DateTime =

我有一个表
flaggedcomment
和一个表
price

flaggedcomment
中,有两个空列
Price\u DateTime
Price\u Open
,我想从
Price
复制,具体取决于
上的
条件。查询如下

UPDATE flaggedcomment as t1 
        LEFT JOIN price as t2 
             ON t1.Ticker_Ticker_ID = t2.Ticker_Ticker_ID AND t1.Comment_DateTime = t2.Price_DateTime
SET t1.Price_DateTime = t2.Price_DateTime, t1.Price_Open = t2.Price_Open
由于
t1.Comment\u DateTime
t2.Price\u DateTime
之间不匹配,此查询将保留一些空值单元格

如果没有找到匹配项,是否有办法“选择”下一个可用的
Price\u DateTime

例如,如果
t1.Comment\u DateTime
的值是
2014-09-29 20:44:00
,但它不存在于
t2.Price\u DateTime
,我可以选择下一行的
Price\u DateTime
值吗,例如
2014-09-30 08:00

我是MySQL查询新手,我已经尽力解释了我想做什么。如果我没有解释好我的问题,请让我知道,我会尝试进一步解释


任何帮助都将不胜感激。谢谢大家!

你能提供一个样本数据和预期结果的小表格吗?@McAdam331嗨,当然。我会更新我的问题,请耐心等待。谢谢。:)根据您的编辑,查看原始两个表中的几行可能会更有帮助,这样其他用户就可以了解这两个表与最后一个表之间的关系。我将浏览其他一些SQL问题,了解如何设置表的格式。否则,创建将允许其他用户重新创建您的问题并尝试解决问题。您可以执行另一个查询,在查询中放置子查询,或更改表以显示下一行中的内容。我会使用子查询。@McAdam331好的,我会改进我的问题。