MySQL database field collation inconsistency arises from an issue

Source: Internet
Author: User

Recently, the project migrated to MySQL, after the migration is complete, when the user permissions are generated an exception, tracked in to get the execution of the statement as follows,

 SELECTPermissionID fromSpysxtpermissionWHERE(resourcecategory= 'Baseuser'         andResourceId=  '003bf4bd072243fa90517ee2bc088cb7'        andEnabled= 1          andDeletionstatecode= 0)UNION  SELECTPermissionID fromSpysxtpermission, (SELECTRoleid fromSpysxtuserroleWHERE(UserId=  '003bf4bd072243fa90517ee2bc088cb7'         andEnabled= 1          andDeletionstatecode= 0)UNION SELECTRoleid fromBaseuserroleWHERE(UserId=  '003bf4bd072243fa90517ee2bc088cb7'         andEnabled= 1          andDeletionstatecode= 0)) BWHEREResourcecategory=  'Spysxtrole'        andSpysxtpermission.resourceid=B.roleid andSpysxtpermission.enabled= 1          andSpysxtpermission.deletionstatecode= 0 

In navicate execution, the following prompts:

This statement is performed in Oracle is normal, for a moment do not know what reason, Baidu did not find how to deal with, I will open the statement one by one execution, finally found the problem here:

 SELECTRoleid fromSpysxtuserroleWHERE(UserId=  '003bf4bd072243fa90517ee2bc088cb7'  andEnabled= 1  andDeletionstatecode= 0)
UNION SELECTRoleid fromBaseuserroleWHERE(UserId= '003bf4bd072243fa90517ee2bc088cb7' andEnabled= 1 andDeletionstatecode= 0)

Seeing here, it occurred to me that there might be a different character set created, open the table

The original problem is in the collation, one is Utf8_unicode_ci, one is utf8_danish_ci. Change all to Utf8_unicode_ci. Problem Solving!

Originally thought is the code bug, has been debugging the code, did not think the problem is here.

MySQL database field collation inconsistency arises from an issue

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.