当前位置:网站首页>Two MySQL tables with different codes (utf8, utf8mb4) are joined, resulting in index failure
Two MySQL tables with different codes (utf8, utf8mb4) are joined, resulting in index failure
2022-07-29 10:15:00 【Jinghu soliton】
1. Problem description
1. log_risk_front ( Risk control incoming log )
There are fields session_id( code utf8), And there's an index index_session_Id
2. risk_result_info ( Risk control incoming parts )
There are fields session_id( code utf8mb4), And there's an index index_session_Id
Two tables ( One to one relationship , adopt session_id relation )
-- Found as follows SQL Can't use index !
SELECT
t1.session_id,
t2.session_id
FROM
log_risk_front t1
INNER JOIN risk_result_info t2 ON t1.session_id = t2.session_id
WHERE
t2.session_id = 'OT742714925312245760'

2. Solution
2.1 Permanent solution , Unified ( library , surface , Field ) Character encoding of , If utf8mb4
ALTER TABLE `log_risk_front`
MODIFY COLUMN `session_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT ' Risk control system session ID';
2.2 A temporary plan 1, use utf8 surface , drive utf8mb4 surface
SELECT
t1.session_id,
t2.session_id
FROM
log_risk_front t1
INNER JOIN risk_result_info t2 ON t1.session_id = t2.session_id
WHERE
t1.session_id = 'OT742714925312245760'

2.3 A temporary plan 2, use CONVERT(expr USING transcoding_name)
SELECT
t1.session_id,
t2.session_id
FROM
log_risk_front t1
INNER JOIN risk_result_info t2 ON t1.session_id = CONVERT(t2.session_id USING UTF8)
WHERE
t2.session_id = 'OT742714925312245760'

3. Relevant reference
边栏推荐
- ORBSLAM2安装测试,及各种问题汇总
- After the thunderstorm of two encryption companies: Celsius repayment guarantee collateral, three arrow capital closed and disappeared
- [ts]Typescript学习记录坑点合集
- Node (II)
- Is it safe to open an account online now? Do you want to know that you must go to the business hall to open an account now?
- 二次握手??三次挥手??
- A Zuo's realm
- SkiaSharp 之 WPF 自绘 弹动小球(案例版)
- Reasons for the rise of DDD and its relationship with microservices
- The purpose of DDD to divide domains, sub domains, core domains, and support domains
猜你喜欢

QoS quality of service five traffic shaping of QoS boundary behavior

基于SSM实现高校后勤报修系统

Consumer electronics, frozen to death in summer

程序员脱离单身的一些建议

通俗易懂讲解梯度下降法!

不堆概念、换个角度聊多线程并发编程

remap_ Use of table in impdp

Orbslam2 installation test and summary of various problems

ECCV 2022 | CMU proposes to recurse on the visual transformer without adding parameters, and the amount of calculation is still small

造型科幻、标配6安全气囊,风行·游艇11.99万起售
随机推荐
This is an incomplete data competition Yearbook!
[log frame]
【黑马早报】每日优鲜回应解散,多地已无法下单;李斌称蔚来将每年出一部手机;李嘉诚欲抄底恒大香港总部大楼;今年国庆休7天上7天...
MySQL优化理论学习指南
The function of that sentence
跟着武老师学高数——函数、极限和连续(持续更新)
12代酷睿处理器+2.8K OLED华硕好屏,灵耀14 2022影青釉商务轻薄本
Shell笔记(超级完整)
Tips of Day1 practice in 2022cuda summer training camp
Does neural network sound tall? Take you to train a network from scratch (based on MNIST)
Reasons for the rise of DDD and its relationship with microservices
Shell notes (super complete)
汉源高科千兆2光6电导轨式网管型工业级以太网交换机支持X-Ring冗余环网一键环网交换机
A little knowledge ~ miscellaneous notes on topics ~ a polymorphic problem
Orbslam2 installation test and summary of various problems
2021年CS保研经历(四):西交软院预推免、信工所三室预推免
How to integrate Google APIs with Google's application system (3) -- call the restful service of Google discovery API
Science fiction style, standard 6 airbags, popular · yachts from 119900
Print out the "hourglass" and the remaining number according to the given number of characters and characters
Vim到底可以配置得多漂亮?