本文介绍了MySQL命令搜索CSV(或类似的数组)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想写一个SQL查询,在一个CSV(或类似)数组中的列中搜索。这里有一个例子:
I'm trying to write an SQL query that would search within a CSV (or similar) array in a column. Here's an example:
insert into properties set
bedrooms = 1,2,3(或1-3)
title = nice property
price = 500
insert into properties setbedrooms = 1,2,3 (or 1-3)title = nice propertyprice = 500
我要搜索where bedroom = 2+。这是可能的吗?
I'd like to then search where bedrooms = 2+. Is this even possible?
推荐答案
通常,这不是你应该如何在关系数据库中存储数据。
Generally, this isn't how you should be storing data in a relational database.
也许你应该有一个 MinBedroom
和 MaxBedroom
。例如:
Perhaps you should have a MinBedroom
and MaxBedroom
column. Eg:
SELECT * FROM properties WHERE MinBedroom > 1 AND MaxBedroom < 3;
这篇关于MySQL命令搜索CSV(或类似的数组)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!