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
This article example shares the specific code of ...
MySQL supports many types of tables (i.e. storage...
Preface The language classification of SQL mainly...
As shown below: #!/usr/bin/env python3.5 import p...
Copy the following code to the code area of Drea...
Preface In order to reflect the difference betwee...
The code can be further streamlined, but due to t...
Table of contents Preface What is Deno? Compariso...
Recently, when developing a small program, I enco...
There are two types of Linux system time. (1) Cal...
Perform the following operations in the Ubuntu co...
Here is a brief summary of the installation and c...
Basic Concepts Before operation, you must first u...
Preface As we all know, the nginx configuration f...
Table of contents 1. Test experiment 2. Performan...