As shown below: LOCATE(substr,str)Returns the first occurrence of substring substr in string str. If substr is not in str, returns 0.
Supplement: LOCATE() method similar to indexOf in MySQL
The first syntax returns the position of the first occurrence of substr in string str. The second syntax returns the position of the first occurrence of the string substr in the string str, starting at position pos. If substr is not in str, the return value is 0. question: There are multiple subjects, multiple choice questions under one subject, and four answers (ABCD) for each question. Count the number of ABCD choices for each question in each subject. SELECT sum( CASE WHEN (LOCATE('A', option name) > 0) THEN 1 ELSE 0 END ) AS A, sum( CASE WHEN (LOCATE('B', option name) > 0) THEN 1 ELSE 0 END ) AS B, sum( CASE WHEN (LOCATE('C', option name) > 0) THEN 1 ELSE 0 END ) AS C, sum( CASE WHEN (LOCATE('D', option name) > 0) THEN 1 ELSE 0 END ) AS D FROM Table name The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me. You may also be interested in:
|
<<: Docker binding fixed IP/cross-host container mutual access operation
>>: JavaScript Reflection Learning Tips
Table of contents Overview Type Assertions in syn...
In fact, we wonder every day when IE6 will really...
Table of contents 1. Usage of keep-alive Example ...
Today, let's talk about a situation that is o...
1. Check whether the existing nginx supports ipv6...
This article shares the specific code for canvas ...
Install Ubuntu 20.04 Install NVIDIA drivers Confi...
background The company code is provided to third ...
Preface When it comes to database transactions, a...
Linux environment variable configuration When cus...
Specific method: 1. Open Command Prompt 2. Enter ...
Key Modifiers When listening for keyboard events,...
Table of contents Effect demonstration:Main JS co...
When we add borders to table and td tags, double ...
Table of contents render.js part create-context.j...