查询:在数据库字段中查找字符串 [英] Query: Find string in database field
本文介绍了查询:在数据库字段中查找字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的数据库表中,我有三个字段。让我们假设字段名称是name,age和favorite_numbers。
In my database table, I have three fields. Let's say the fields names are name,age, and favorite_numbers.
现在,我的数据库的内容如下:
Now, the contents of my database are as follows:
- Anna是15岁,她最喜欢的数字是14,21,16
- Jessica是20岁,她最喜欢的数字是21,30, 20
- Sara是30岁,她最喜欢的数字是50,45,21
- Jessa是12岁,她最喜欢的数字是 12,20
- Farrah是19岁,她最喜欢的数字是6,12,20
- Anna is 15 and her favorite numbers are "14,21,16"
- Jessica is 20 and her favorite numbers are "21,30,20"
- Sara is 30 and her favorite numbers are "50,45,21"
- Jessa is 12 and her favorite numbers are "10,12,20"
- Farrah is 19 and her favorite numbers are "6,12,20"
如何制作我的查询以查看拥有最喜爱数字21的人的姓名?
How do I formulate my query in order to view the names of the people whose has the favorite number of 21?
在上面的内容中,我想显示Anna,Jessica和Sara的名字,因为他们中的三个有21个最喜欢的数字。
In the contents above, I wanted to display Anna, Jessica and Sara's names only since the three of them has the favorite number of 21.
推荐答案
>
i假设你的表名是 user
(你没有给出表名)。
Try this query :
i imagine that your table name is user
(you didn't give the table name).
SELECT * FROM user WHERE favorite_numbers like '%21%'
这篇关于查询:在数据库字段中查找字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文