database - MySQL Insert in table if it doesn't exist already ¿Am I doing it right? -


While creating my application with the relational tables, I participated in the following problem:

I have The following table is for this example named "Valores":

  ----------------------- | ID | Price | ----------------------- | 1 | Unique Valve | | 2 | Unique VAL2 | ----------------------- ID = etinininkment value = unique  

What am I trying to do? Price if it is not already present, the way I am doing it now is:

  Enter values ​​(id, value) values ​​(zero, "unique VAL2") Do;  

So it will not do anything because price already exists. Now my question is:

¿What is the best and fastest way to do this is?

I think this is the best way for your scenario

For different purposes you can use the duplicate key on update or

Read more:


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -