How to join two table table with different data types? in the first table status field type is enum and in second table it is int, how i can join these tables
-
3Could you give an example of what the tables look like? (schemas/contents)Joachim Isaksson– Joachim Isaksson2012-04-19 12:42:17 +00:00Commented Apr 19, 2012 at 12:42
-
2Really it should just be an INT in both columns. Normally an ENUM would be used for storing strings where there are only specific strings used.Simon at The Access Group– Simon at The Access Group2012-04-19 12:42:40 +00:00Commented Apr 19, 2012 at 12:42
-
Just try the with joins on those columns and see if there is any issue. ENUM values are anyways integer and so should not be a issue joining them with a int field (That's a Guess though).Rahul– Rahul2012-04-19 12:45:53 +00:00Commented Apr 19, 2012 at 12:45
Add a comment
|
1 Answer
Enum type is stored by MySQL as an int, so you can do the join as usual. But in case both fields were different you should cast one of them to make their types match if possible (usually with cast functions http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html)