我有一个拥有username,ipaddress,timestamp
我想将这些详细信息存储在UserDetailsTable
(内存表中)中,并且需要执行 upsert 。
如果username和ipaddress相同,我怎么能更新行,否则插入新行。
例如:
Ist userStream is "Rockey","192.15.12.11","10-10-2015 10.32"
2nd userStream is "Jose","192.15.12.21","10-10-2015 10.33"
3rd userStream is "Rockey","192.15.12.11","10-10-2015 10.34"
UserDetailsTable的结果在
之下"Jose","192.15.12.21","10-10-2015 10.33" (New row)
"Rockey","192.15.12.11","10-10-2015 10.34" (Update the existing row)
答案 0 :(得分:0)
您可以使用以下方法。
from userStream
select username, ipaddress ,timestamp
update UserDetailsTable
on UserDetailsTable.username == username
请注意,流属性和事件表属性必须相同。希望这会有所帮助。
感谢。