mysql - it is possible to prevent insert/updates in sql relating to 2 different columns in a table? -


im trying figure out method sql-side (mysql) prevent inserting or updating data depending on columns. depending on data in 1 column, other 1 isnt allowed have same , via versa. example:

╔═══════════╦═══════════╦════════════════════════════╗ ║   col1    ║   col2    ║            ok?             ║ ╠═══════════╬═══════════╬════════════════════════════╣ ║ 168068786 ║           ║ ok                 ║ ║           ║ 636435623 ║ ok                 ║ ║ 536733246 ║ 356367235 ║ ok                 ║ ║ 526372123 ║ 526372123 ║ isnt ok (same values) ║ ╚═══════════╩═══════════╩════════════════════════════╝ 

is possible via constraints? or other method? dont quite how achieve if indeed possible via constraints. appreciated

this can achieved trigger-functions called before doing insert/update. check documentation details


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -