MySQL Forums
Forum List  »  Newbie

sql query with check constraint pct
Posted by: Amit Kumar
Date: June 08, 2023 08:42AM

Getting an error with following sql query with mysql v8 which was working with v5.7.

Create table test (
empId char(36) not null,
tolerance decimal(5,2) not null check (pct > 0 and pct <= 100),
primary key (empId)
);

ERROR 3813 (HY000): Column check constraint 'test_chk_1' references other column.


Please do explain the query and corresponding correct query for mysql 8.

Options: ReplyQuote


Subject
Written By
Posted
sql query with check constraint pct
June 08, 2023 08:42AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.