首页 \ 问答 \ 如果数据不存在(不包括主键),则插入MySQL(MySQL insert if data doesn't exist(excluding primary key))

如果数据不存在(不包括主键),则插入MySQL(MySQL insert if data doesn't exist(excluding primary key))

我只是在表中没有数据的情况下尝试执行sql插入。 我有一个语言表,它有一个自动递增的主id字段和一个字符串描述字段来捕获语言的名称(例如英语)。 我希望只有在描述字段不存在时才能插入数据库。 主要ID无关紧要。 所以我只想插入表中,如果“英语”不是表中的值。 另外,我只给出了描述以检查它是否已经存在于数据库中(我提到这是因为ON DUPLICATE KEY要求所有字段都匹配,而我没有id)。

我搜索并尝试了很多查询,但没有任何查询产生正确的结果。 任何想法都会有所帮助。 谢谢。


I am trying to do a sql insert only if the data doesn't already exist in the table. I have a language table that has a auto incremented primary id field and a string description field to capture the name of the language(ex. English). I want to be able to insert into the database only if the description field is not already there. The primary id doesn't matter. So I only want to insert into the table if "English" isn't already a value in the table. Also, I am only given the description to check if it's already in the database (I mention this because the ON DUPLICATE KEY requires all fields to be matching and I don't have the id).

I have searched and tried so many queries without any of them producing the correct results. Any ideas would be helpful. Thanks.


原文:https://stackoverflow.com/questions/34499785
更新时间:2022-04-24 06:04

最满意答案

ExternalInterfacefscommand的直接替代品, fscommand是Flash和容器应用程序之间通信的旧方法(Flash前播放器8)(请参阅Adobe文档 )。

再次从文档中, ExternalInterface优于fscommand的优点如下:

  • 您可以使用任何JavaScript函数,而不仅仅是可以与fscommand()函数一起使用的函数。
  • 您可以使用任何名称传递任意数量的参数; 您不仅限于传递命令和单个字符串参数。 这为外部API提供了比fscommand()更大的灵活性。
  • 您可以传递各种数据类型(例如Boolean,Number和String); 您不再局限于String参数。
  • 您可以接收调用的值,该值立即返回到ActionScript(作为您调用的返回值)。

如果您的目标是Flash Player 8或更高版本,则建议您使用ExternalInterface


ExternalInterface is a direct replacement for fscommand, which was the old method (pre Flash player 8) of communicating between Flash and the container application (see Adobe documentation).

From the documentation again, the advantages of ExternalInterface over fscommand are as follows:

  • You can use any JavaScript function, not only the functions that you can use with the fscommand() function.
  • You can pass any number of arguments, with any names; you aren't limited to passing a command and a single string argument. This gives the external API much more flexibility than fscommand().
  • You can pass various data types (such as Boolean, Number, and String); you are no longer limited to String parameters.
  • You can receive the value of a call, and that value returns immediately to ActionScript (as the return value of the call you make).

If you're targeting Flash Player 8 or later the recommendation is that you use ExternalInterface.

相关问答

更多
  • 看一下这个线程,它讨论了使用ExternalInterface的一些挑战: http : //forums.epicgames.com/threads/802762-Developing-Scaleform-UI-with-Vectorian-Giotto Take a look at this thread, which talks about some challenges with using ExternalInterface: http://forums.epicgames.com/threads ...
  • ExternalInterface.objectId为您提供显示SWF的HTML元素的ID。 使用它来访问SWF元素并通过它来访问父节点。 var getParent:String = 'function (objectId) { return document.getElementById(objectId).parentNode.id; }'; if (ExternalInterface.available) trace(ExternalInterface.call(getParent, Ex ...
  • ExternalScript 2.0(从Flash Player 8开始)和3.0都可以使用ExternalInterface。 两者的用法非常相似,但这是AS2中的一个例子: http://blog.deconcept.com/2005/08/16/external-interface/ ExternalInterface is available in both Actionscript 2.0 (starting with Flash Player 8) and 3.0. The usage is p ...
  • 只需再次调用addCallback,将函数设置为null: ExternalInterface.addCallback("callAlert", null); 文档提到了这一点: ExternalInterface.addCallback() 注意:在具有null闭包值的现有回调函数上重复addCallback()将删除回调。 Just call addCallback again, setting the function as null: ExternalInterface.addCallback(" ...
  • 对于具有不同安全要求的JavaScript / Flash通信,有几种不同的方案。 SWF和HTML的协议和域匹配。 JavaScript可以与Flash通信。 如果参数allowScriptAccess设置为"sameDomain" (默认)或"always"则Flash可以与JavaScript通信。 例如, http://example.com/a.swf加载在http://example.com/a.html上 SWF和HTML的域不同。 如果从Flash调用Security.allowDomain ...
  • 我建议从我的文章中尽可能简单地尝试它, http://work.arounds.org/issue/10/calling-flash-functions-from-javascript/