0

I have two tables question and question_paper . in question_paper i have a column named question_ids .in question_ids-(text type) i stored the question table's id like 2,5,23,45,6,9 etc. now the problem is when i trying to fetch the data using

select * from question where id IN (select question_ids from question where id=1) it passes the question_ids as a string type so it returns only first matched id's value.so, i need to change this query result as a number type is it possible in mysql or is there any function using i can change the type temporary.thanks in advanced.

Alfiza malek
  • 994
  • 1
  • 14
  • 36
  • 1
    Have you tried CAST() or CONVERT()? Just google "mysql cast" – yahermann Jan 03 '16 at 17:43
  • Try this [SO post](http://stackoverflow.com/questions/17942508/sql-split-values-to-multiple-rows) to first split your question_id string into rows and then use that for your sub-query. I think that should work. – vmachan Jan 03 '16 at 17:45

1 Answers1

-1

MySQL CAST() function to convert a value of any type into a value with a specified type. http://www.mysqltutorial.org/mysql-cast/

Vipin Jain
  • 3,686
  • 16
  • 35