About the mysql8 database using select distinct to query unique data and use unqueried time sorting to solve the query error

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

Red Fatty Network Technology's Blog Encyclopedia: Development technology collection (including Qt practical technology, Raspberry Pi, 3D, OpenCV, OpenGL, ffmpeg, OSG, single-chip microcomputer, combination of software and hardware, etc.) is continuously updated...

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;

  insert image description here
 &emspl; The customer’s error is as follows (reminder that the sorting attribute needs to be in select disctinct):
insert image description here
  On the development machine, it is as follows:
  insert image description here

  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

  insert image description here


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 = '弦向' );

  insert image description here

  insert image description here


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

Guess you like

Origin blog.csdn.net/qq21497936/article/details/130247352