MySQL joining tables on fields with different type

2015-01-12T23:03:44

Suppose I have 2 InnoDB tables A and B.

Table A has a column named Acountry of type INT
Table B has a column named Bcountry of type VARCHAR

Some records in table A have in column Acountry values "356"
Some records in table B have in column Bcountry values "356,Italy"

How is it possible that the following join works perfectly: (I mean I get rows where Acountry or Bcountry starts with 356)

SELECT A.Field1 , A.Field2 , B.Field3 , B.Field4 
FROM A
JOIN B ON A.Acountry=B.Bcountry

despite the fact that the 2 columns have different values and are of different type

Any hints ? Is there any setting for "loose" joining ?

P.S. I found this link http://bugs.mysql.com/bug.php?id=3777 where it states that: "This is expected behavior. The arguments (string and number) are compared as floating-point numbers" ???

Copyright License:
Author:「Portishead」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/27904944/mysql-joining-tables-on-fields-with-different-type

About “MySQL joining tables on fields with different type” questions

Suppose I have 2 InnoDB tables A and B. Table A has a column named Acountry of type INT Table B has a column named Bcountry of type VARCHAR Some records in table A have in column Acountry values ...
I am aware that there are multiple posts about this, but I was not able to make it work for my code. As the title suggests I want to join two tables from two different DBs together. Here is my c...
was wondering if joining tables is the best way to retrieve data from multiple columns like i want to retrieve the fields from two columns in a table and one column from another table. I was wonde...
I have three table that I want to join by id. The first is the main containing always all informations on attributes. The others two could have null value for a certain id. In the result table I wa...
It can be concatenate fields in a table. But I want to know if you can concatenate two fields where "a" is in categories table and the "other" is in the products table, bone in different tables with
I have 2 different tables in a mySQL database that are structured like this: table_cart: cart_id | item_id | quantity ---------------------------- 00001 285 1 00002 482 2 0000...
I always have confusion when it comes into JOINING tables. So, I have a table that stores the user details called tblUsers having the following fields(for the sake of simplicity, I am including on...
I am trying to join two tables using mysql, this is not difficult, my problem is the column I am joining on has a nonstandard type, I am joining on the birthday column which can come in a variety of
I found help at this topic: Search different column names in different tables in MySQL but they are only referencing two fields per table in that topic and I wasn't able to generate an answer from my
I have 2 tables : table 'g' +------+ | id | +------+ | 1 | | 32 | | 3 | | 6 | | 5 | | 22 | | 54 | | 21 | +------+ table 'h

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.