当没有行时如何插入行
我有一个应用程序,需要部署给客户。通过以下方式检查他们是否已订阅该应用程序。
他们的数据库中会有一个表。如果此表中已有条目,那么我可以将我的模块添加到其中。记录看起来像这样。
MODULE_ID 描述 DISPLAY_TEXT ACTIVE 12 Census NULL 1
我所要做的就是将我的模块添加到代码中。我有 16 和 17 模块 ID,名称是“Orders”和“Missed Medicine”。
Module_ID 的长度为 18 数字
描述为 varchar(50)
Display_test varchar(25) 允许空值。
Active 是 1 个数字,允许空值。
我需要编写 INSERT 代码,但前提是表中已存在此类行。最好的方法是什么?
I have an app and need for deploying to customers. to check in the following way if they have subscribed to the app.
they will have a table on their database. If there are aleady entries in this table, then I can add my modules to it. The record looks like this.
MODULE_ID DESCRIPTION DISPLAY_TEXT ACTIVE
12 Census NULL 1
All that I have to do is to add my modules to this in the code. I have 16 and 17 module ID and the names are 'Orders' and 'Missed Medicine'.
Module_ID is len of 18 Numberic
Description is varchar(50)
Display_test varchar(25) allows nulls.
Active is 1 numeric allows nulls.
I need to code the INSERT but only if there are such rows already in the table. what is the best way for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用以下内容:
You could use the following:
“SELECT COUNT(*) FROM YourTable;”
如果返回的值大于 0,则可以插入。
´SELECT COUNT(*) FROM YourTable;´
If that returns more then 0, you can insert.