SQL查询检查Mysql表中某些键是否存在
我在我的应用程序中输入了一些静态文本键
。我的应用程序还有一个可以使用的键
表。我想编写一个查询来检查表中是否存在所有这些静态键。如果有些丢失了,我想知道它们是什么key
。
这是一个示例表...
+----------+
| column |
+----------+
| val1 |
+----------+
| val2 |
+----------+
| val3 |
+----------+
在此示例中,我想检查表中不存在哪些静态值 val1,val3,val4,val5
。我该如何编写查询来实现此目的?
I have some static text keys
entered as part of my app. My app also has a table of keys
that can be used. I want to write a query that checks whether all of those static keys
exists in the table. If some are missing, I want to know what keys
they are.
Here is an example table...
+----------+
| column |
+----------+
| val1 |
+----------+
| val2 |
+----------+
| val3 |
+----------+
In this example, I want to check which of the static values val1,val3,val4,val5
don't exists in the table. How can I write a query to achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
或者
可以在子查询中使用
distinct
示例
您所需要的就是这个
,然后如上所述使用该临时表。我确信一定有更好的方法。
请参阅此处 http://dev.mysql.com/doc/refman /5.1/en/create-table.html
or
May use
distinct
in sub-queryAn Example
All you need is this
and then use this temp table as mentioned above. I am sure there must be a better method.
see here http://dev.mysql.com/doc/refman/5.1/en/create-table.html