i have 3 tables with 81 recrods and similar columns (just one got a column less then others) , here is an example :
when i join the 3 tables using a normal join or an inner join :
SELECT DISTINCT *
FROM target
INNER JOIN demons ON demons.Year = target.Year
INNER JOIN violence ON violence.Year = target.Year;
i get duplicated rows like this :
they have the same Month and Year values I want to be able to join them without duplicates according to Year and Month
CodePudding user response:
You would at least need to include a condition to match the month as well as the year:
SELECT *
FROM target
INNER JOIN demons
ON demons.Year = target.Year AND demons.Month = target.Month
INNER JOIN violence
ON violence.Year = target.Year AND violence.Month = target.Month