gpt4 book ai didi

MySQL 2表,插入前查询

转载 作者:行者123 更新时间:2023-11-29 02:29:55 25 4
gpt4 key购买 nike

我很困惑,这就是我所拥有的。

两张表,一张是临时的,一张是永久的。

 table  Temptable:   
city , state //- has a list of 20 citys and states

table Permtable:
city , state //- has hundreds of citys and states

我想做两件事:

  1. 我想使用 Temptable 中的城市和州并查询 Permtable 以查看它是否已包含那个城市和州。如果没有,我希望它添加它。

  2. 如果它在城市和州中匹配,我希望它播放 c:\sound.wav 然后我希望它添加到

可渗透。

我不知道该怎么做。

最佳答案

这将告诉您哪些记录存在或不存在于您的临时表中:

SELECT T.City, T.State, CASE WHEN P.State IS NULL THEN 'DOES NOT EXIST' ELSE 'DOES EXIST' END
FROM TempTable T
LEFT JOIN PermTable P ON T.City = P.City AND T.STate = P.State

您可以像这样插入那些不存在于 PermTable 中的记录:

INSERT INTO PermTable
SELECT T.City, T.State
FROM TempTable T
LEFT JOIN PermTable P ON T.City = P.City AND T.STate = P.State
WHERE P.State IS NULL

不确定您播放声音的要求,然后添加它没有意义(因为它已经存在)。

关于MySQL 2表,插入前查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14823616/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com