因为我们的数据库中有个字段的存储方式为‘,2017,2018,2019,’,但是在查询出来展示的时候肯定不能这样展示,所以我就想在查询的时候去除这个字段前后的逗号,百度了很久没有找到答案,经过一位大神的提点,终于找到了方法,sql如下:
SELECT
t.content singleContent,
t.id singleId,
t.has_error singleHasError,
t.checked singleChecked,
TRIM(BOTH ',' FROM t.`year`) singleYear,
t.difficulty singleDifficulty,
s.type
FROM
survey_topics s
LEFT JOIN single_topics AS t ON s.topic_id = t.id
AND s.type = 'SINGLE'
where s.survey_id = '123456'