MySQL Forums
Forum List  »  General

JOIN BETWEEN 2 TABLES WITH DIFFERENT ID COUNTING
Posted by: Roberto B.
Date: November 27, 2015 10:33AM

Starting from 2 same structure tables A and B

CREATE TABLE A (
`id` mediumint(9) NOT NULL AUTO_INCREMENT,
`NAME` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16384 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

but in A and B relative id to the same value of NAME can be different.

How can i get id of a table (let's say A) starting from each value of NAME in B?
I was using JOIN in many ways but getting always null results.
For example:

SELECT a.id FROM A
JOIN B
ON A.NAME = B.NAME;

Options: ReplyQuote


Subject
Written By
Posted
JOIN BETWEEN 2 TABLES WITH DIFFERENT ID COUNTING
November 27, 2015 10:33AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.