mysql 如何比较两个字符串之间的字符串和 return 行

mysql how to compare strings and return rows between two strings

我怎样才能简单地按字母过滤 table 行,例如仅显示字符串以 efg 开头的行并排除其他行。

类似

return (rows > "d") andalso (rows < "h")

vb.net

如果需要正则表达式,可以使用like。例如,这将为您提供所有以 a:

开头的行
select * from myTable where myColumn like 'a%';

编辑:

我明白你的意思了,mysql 也支持字符串的 > 和 <,所以如果你这样做:

where col >= 'e' and col < 'h'

您基本上会得到以 e,f,g 开头的所有内容

您可以组合多个 LIKE 运算符说

select * from table1
where mycol like 'e%'
or mycol like 'f%'
or mycol like 'g%';

(或)您可以使用 LEFT() 字符串函数 saying

select * from table1
where left(mycol,1) in ('e','f','g');