我有这样的表有两行
UID & ids
1 & 2.3
2 & 5
3 & 4
4 & 1.2
等
我用gruop_concat()
查询
select *
from tbltable
where tableId Not In(
SELECT tableId
FROM `tblbooking`
where restaurantid = 1
and date(starttime) = date(p_starttime)
and Time(StartTime) >= Time(p_starttime)
And Time(EndTime) <= Time(p_endtime)
)
and NoOfSeats >= p_noofseats
它返回“2,3,4,5,1,2”但我想要逗号分隔的值而不是字符串2,3,4,5,1,2
答案 0 :(得分:0)
这与子串
是完全相同的SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(maintable.choices,',',othertable.id),',', - 1)AS选择 从维护INNER JOIN othertable ON (LENGTH(选项)&gt; 0 AND SUBSTRING_INDEX(SUBSTRING_INDEX(选项,',',othertable.id),',', - 1) &LT;&GT; SUBSTRING_INDEX(SUBSTRING_INDEX(choices,',',othertable.id-1),',', - 1));
请检查此链接 http://www.tero.co.uk/scripts/mysql.php
谢谢。