If this article is an original article, please indicate the source of the original article when reprinting.
The blog address of this article: https://hpzwl.blog.csdn.net/article/details/130247352
Database related development
question
The mysql8 database uses select distinct to query unique data and uses unqueried time sorting to cause a query error. The same database is installed on an unreachable machine, and this problem occurs on the client machine, but the development machine in the headquarters does not have this problem. First of all, the deployment environment and operation cannot be completely avoided, so a compromise solution should be chosen to reduce the probability of errors.
try
Attempt 1: Both sides use mysql's navicat to query
select distinct shiJianLeiXing, chengXingFangXiang, yuYingLiShuiPing, sheBeiXingHao, penZuiGuiGe, penZuiZhiJing, danWanGuiGe, danWanLiuLiang, youXiaoDaiKuan, penSheJuLi, penSheJiaoDu from ames_k_peeening_test_piece_forming_knowledge_info where ( shiJianLeiXing = '基础件' ) and ( chengXingFangXiang = '弦向' ) order by chuangJianShiJian desc;
&emspl; The customer’s error is as follows (reminder that the sorting attribute needs to be in select disctinct):
On the development machine, it is as follows:
The same statement has problems on the server deployed by the customer, the reason is unknown.
Attempt 2: Use the sorting in select distinct, it doesn't work
solve
Sorting is no longer used, because other selected sorts also fail, and queries cannot be made, and the specific reason is unknown.
select distinct shiJianLeiXing, chengXingFangXiang, yuYingLiShuiPing, sheBeiXingHao, penZuiGuiGe, penZuiZhiJing, danWanGuiGe, danWanLiuLiang, youXiaoDaiKuan, penSheJuLi, penSheJiaoDu from ames_k_peeening_test_piece_forming_knowledge_info where ( shiJianLeiXing = '基础件' ) and ( chengXingFangXiang = '弦向' );
If this article is an original article, please indicate the source of the original article when reprinting.
The blog address of this article: https://hpzwl.blog.csdn.net/article/details/130247352