当前位置:网站首页>Method of querying comma separated strings in a field by MySQL
Method of querying comma separated strings in a field by MySQL
2022-07-24 17:00:00 【ILHONG】
mysql A way to query a comma separated string in a field
List of articles
Preface
Now there are the following scenes . We have a case table . Each case corresponds to multiple tags , One tag corresponds to one case . When we do paging at the front desk , Multiple tags need to be matched
The data structure of the table is as follows
One 、 First, let's talk about a requirement
We need to find out crowd_label_id by 4,6,9 All of the case_id 4,6,9 Is and condition
- First, find the corresponding case_id All satisfied labels That is, row to column Use
GROUP_CONCATfunction
- After the query, we will know the corresponding case_id All the labels .
- The rest is if according to label_id To make a match . That's when we can use it mysql function
FIND_IN_SETTo match whether the specified label exists in the string . Of course, this step can also be put into the program to make judgments .
The result is a perfect match label_id contain 4,9 All of the case_id
Enclosed sql
SELECT * FROM (
SELECT case_id,GROUP_CONCAT(crowd_label_id) AS aa FROM weapp_case_label WHERE crowd_label_id IN (4,6,9) GROUP BY case_id
) AS aaa WHERE FIND_IN_SET('4', aa) AND FIND_IN_SET('9', aa)
summary
The main knowledge here is mysql Row column of , There are multiple rows of data that can be displayed in a column .
边栏推荐
- 详解 Apache Hudi Schema Evolution(模式演进)
- Pull and load more on wechat applet list rendering
- Long awaited full platform support - Open Source im project uniapp update of openim
- JVM class loading subsystem
- PS pull out logo
- Why can't sizeof (ARR) / size (arr[0]) be used to calculate the array length inside the called function?
- 查数据库实际数据增长情况
- quick get start
- 【时序逻辑电路】——计数器
- Cann training camp learns the animation stylization and AOE ATC tuning of the second season of 2022 model series
猜你喜欢

1184. Distance between bus stops

Thinkphp3.2.5 cannot jump to external links

QT graphical interface beginner project - unmanned aerial vehicle group combat simulation

Apachecon Asia 2022 opens registration: pulsar technology issues make a big debut

Qsqldatabase: solution of qmmysql driver not loaded

AXI协议(1):AMBA总线介绍,AXI概念与背景介绍,AXI协议特点与功能

Envi SHP to ROI and mask the grid

Still developing games with unity? Then you're out. Try unity to build an answer system

Small end format and big end format (little endian & big endian)

Sword finger offer 48. the longest substring without repeated characters
随机推荐
Custom types: Enumeration
Using unity to do simulation, I don't allow this chart plug-in, you don't know
详解 Apache Hudi Schema Evolution(模式演进)
Envi5.3 open GF-1 WFV data
What are the safe securities companies? I want to buy stocks on my mobile phone
Picture browser? QT can also be achieved!
AMD锐龙7000预计9月15日上市 3D缓存版还要再等等
期盼已久全平台支持-开源IM项目OpenIM之uniapp更新
Simply use MySQL index
Summary of experience in using.Net test framework xUnit, mstest, specflow
【零基础】充分理解WebGL(八)
How to effectively avoid memory leakage when customizing the handler?
Getting started with arcpy
QT design simulation robot controller
Mcd12q1 data shows multiple classifications in envi
【技术】uniapp 之 在线选座 demo
EF combined with sqlbulkcopy batch insert data
Meeting OA project progress (I)
[redis] -1. two ways of setting up environment based on docker
QT QML virtual keyboard
