我正在编写以下查询:
SELECT * FROM notes inner join item_source
on notes.item_ids=CONCAT(CONCAT(',', cast(item_source.id as varchar(10))), ',')
item_source.id
是table的主键(数字,auto_increment)item_source
。notes.item_ids
是varchar
表注释的字段。
我想item_source.id
=18
匹配notes.item_ids
= ',18,'
。
我收到以下错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'varchar(10))), ',')
我究竟做错了什么?
您需要将其转换为 char 数据类型,然后您才能得到结果
SELECT * FROM notes内连接item_source on notes.item_ids=CONCAT(CONCAT(',', cast(item_source.id as char(10))), ',')
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句