我有两个表问题和question_paper。在question_paper我有一个名为question_ids .in question_ids-(文本类型)的列,我存储问题表的ID像2,5,23,45,6,9等。现在的问题是,当我试图取数据使用如何更改mysql查询中的数据类型?
select * from question where id IN (select question_ids from question where id=1)
它将question_ids作为字符串类型传递,因此它只返回第一个匹配的id的值。因此,我需要将此查询结果更改为数字类型,这在mysql中是可能的,还是有任何函数使用我可以更改临时类型。先谢谢了。
您是否尝试过CAST()或CONVERT()?只是谷歌“mysql铸” – yahermann
使用CAST()函数 –
试试这个[SO帖子](http://stackoverflow.com/questions/17942508/sql-split-values-to-multiple-rows)首先拆分你的question_id字符串到行中,然后将其用于您的子查询。我认为这应该工作。 – vmachan