gpt4 book ai didi

ms-access - 从表中选择值,其中逗号分隔字符串中的值

转载 作者:行者123 更新时间:2023-12-04 10:11:28 28 4
gpt4 key购买 nike

这是我的第一篇文章...
我正忙着在 Access 2010 中编写一个软件。我的 SQL 还不错,但在这里我有点难住了。

我有一个具有以下布局的表格

ID = AutoNumber, 
Category = Text,
SubCategory = Text,
Grades = Text.

以及以下数据
ID  Category    SubCategory   Grades
2 Behaviour Good RRR,RR,R,1,2,3,4,5,6,7,8,9,10,11,12
3 Behaviour Not so Good RRR,RR,R,1,2,3,4,5,6,7,8,9,10,11,12
4 Health Doctor Note RRR,RR,R,1,2,3,4,5,6,7,8,9,10,11,12
5 Social Peer Pressure
6 Academics General Academic Knowledge 1,2,3
7 Academics Additional Academic Knowledge 1,2,3
8 Gross Motor Skills Kicks a ball that is moving towards him or her.
9 Gross Motor Skills Hops and jumps while in motion R
10 Gross Motor Skills Skips RR
11 Gross Motor Skills Gallops RR
12 Gross Motor Skills Jumps forward 10 times RR
13 Gross Motor Skills Catches a small bounced ball RR
14 Gross Motor Skills Turns somersault RR
15 Gross Motor Skills Alternates feet walking up or down stairs RR`

我正在尝试创建一个我选择的查询,例如
SELECT SubCategory from CATEGORY WHERE GRADES LIKE R

它应该返回
Good
Not so Good
Doctors Note
Peer Pressure
Hops jumps and Skips

显然,如果我需要等级 RRR 或 1、2 或 5,则应根据需要进行选择

请任何人都可以提供帮助。
谢谢
沃伦

最佳答案

您可以使用运算符 LIKE 来完成此操作这边走:

SELECT SubCategory 
FROM CATEGORY
WHERE ',' + GRADES + ',' LIKE '*,R,*'

或者如果你想要查询的值 'R'单独作为参数:
SELECT SubCategory 
FROM CATEGORY
WHERE ',' + GRADES + ',' LIKE '*,' + 'R' + ',*'

关于ms-access - 从表中选择值,其中逗号分隔字符串中的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61320326/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com