员工表
Id Name Salary frame
1 A 5000 MDF-125NH
2 b 10000 MDF-025AH
3 c 15000 MDF-325KH
4 d 20000 MDF-425LH
5 e 25000 MDF-521MH
我想从mysql获取到帧之间的数据,即(mdf-125nh,mdf-325kh)。
我尝试了一些东西,但没有成功。
SELECT DISTINCT (id) AS ln
FROM employee c04 BETWEEN (
SELECT SUBSTRING(frame, 0, CHARINDEX('-', frame))
FROM employee
) AND (
SELECT SUBSTRING(frame, 0, CHARINDEX('-', frame))
FROM employee
) )
或
SELECT DISTINCT (id) AS ln
FROM employee c04 BETWEEN (
SELECT SUBSTRING("MDF-125NH", 0, CHARINDEX('-', "MDF-125NH"))
FROM employee
) AND (
SELECT SUBSTRING("MDF-325KH", 0, CHARINDEX('-', "MDF-325KH"))
FROM employee
) )
1条答案
按热度按时间olhwl3o21#
结果如下:
sql中的“between”具有非常具体的含义,相当于:
这个定义可能不一定与你所期望的一致。
此查询:
产生以下结果:
看到这个了吗