我使用CONCAT获取我的标签和主题,但如果故事没有标签或主题,则结果为空
WHERE
CONCAT( ' ', table_stories.tags, ' ' )
LIKE CONCAT( '%', table_tags.tid, '%' )
AND
CONCAT( ' ', table_stories.associated, ' ' )
LIKE CONCAT( '%', table_topics.topicid, '%' )
如你所见,一切正常,除非我们的故事没有标签或相关的
我用过
table_stories.tags IS NULL OR
但问题仍然存在,无法获取没有标记或关联的故事
我该如何解决这个问题
答案 0 :(得分:3)
我没有mysql方便测试,但COALESCE()
可能是你正在寻找的功能。
这将返回第一个非null参数(参见Documentation)
所以
CONCAT(' ' , COALESCE(table_stories.associated, ' '), ' ')
应该做的工作