Answer the question
In order to leave comments, you need to log in
How to unload all the fields, due to which, when adding a row, it may give an error due to the uniqueness of the data?
I have a table with 10 columns. There is a unique key on 7 columns, and if you try to add some line, and suddenly it does not pass through the uniqueness, it gives an error due to the unique key. It is necessary to unload all records due to which it can give an error due to uniqueness. I can’t figure out how to do it, I need help)
example (from my head) there are columns
category, subcategory, sub-subcategory, action to be done
And the table has already set values for some record, for example:
category: 1, subcategory: 2: sub-subcategory: 5, action to be taken: 2
There is a unique key on the first three columns. If we want to add something with another "action to be done" for sub-subcategory 5 (for example, with the number not 2, but 3 already), then we will get an error, because the unique key is on the first three columns. Here, and you need to unload all the records that prevent you from adding a record
Answer the question
In order to leave comments, you need to log in
It is necessary to unload all records due to which it may give an error due to uniqueness
SELECT * FROM qTable WHERE qField = qValue
Check if there is a record with a similar set of fields?
The result of this query will be one record, "interfering" with adding a new record.
If a duplicate entry must be added, expand the size of the unique index, add an `action` column to it. Or in a new post, change `subcategory`/`sub-subcategory`.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question