Check for unique column value

QuestionsCheck for unique column value
Bill asked 7 years ago

Is there a way to check the value in a column to make sure that no other rows have the same value in the same column?

EXAMPLE: A MySQL table has a UserCode column. Each row in the table must have a unique value for this column. If an attempt is made to enter a UserCode that already exists, then I want to show an error message.

In the UserCode column, I am using a custom edit function.

Any help would be appreciated…thanks!

P.S. — If the custom edit was PHP function, then I could easily do what I need, but it looks like the custom edits all have to be written in JavaScript.

2 Answers
Abu Ghufran answered 7 years ago

Hello,

Please refer demos/editing/server-validation.php.
It has working example how to apply unique and other business checks and show message on client.

Bill answered 7 years ago

Thanks again, Abu…this is exactly what I needed (when reviewing the demo scripts, I missed this somehow).

Your Answer

13 + 12 =

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating / 5. Vote count:

We are sorry that this post was not useful for you!

Let us improve this post!