患者信息表: Patients
+--------------+---------+
| Column Name | Type |
+--------------+---------+
| patient_id | int |
| patient_name | varchar |
| conditions | varchar |
+--------------+---------+
patient_id (患者 ID)是该表的主键。
'conditions' (疾病)包含 0 个或以上的疾病代码,以空格分隔。
这个表包含医院中患者的信息。
写一条 SQL 语句,查询患有 I 类糖尿病的患者 ID (patient_id)、患者姓名(patient_name)以及其患有的所有疾病代码(conditions)。I 类糖尿病的代码总是包含前缀 DIAB1 。
按 任意顺序 返回结果表。
来源:力扣(LeetCode)
select patient_id,patient_name,conditions
from Patients
where conditions like '% DIAB1%' or conditions like 'DIAB1%';
% 匹配多个字符
“DIAB1%”是查询该类在排头的情况;
“% DIAB1%”是查询该类处在后面的情况,如果类型中的信息中存在者最后一个测试用例的情况:”XXXDIAB1…..”,加上的空格可以排除
Original: https://www.cnblogs.com/aLiuLiu/p/16547179.html
Author: 阿榴
Title: Sql的字符串匹配 like
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/643792/
转载文章受原作者版权保护。转载请注明原作者出处!