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
Post a Comment