So I am trying to return only the records that are set to default from a mapping table but it is setting all languages to default related to that item from that market. Bellow is the exact sql I am using.
SELECT `teams`.*,
`markets`.`title` AS `market`,
`markets`.`short_name`,
`market_countries`.*,
`countries`.`title` AS `country`,
`languages`.`title` AS `language`,
`languages`.`short_code`,
`status`.`title` AS `status`,
`team_types`.`title` AS `type`,
`market_languages`.*
FROM `teams`
JOIN `markets` ON teams.market_id = markets.id
LEFT JOIN `market_countries` ON markets.id = market_countries.market_id
LEFT JOIN `countries` ON countries.id = market_countries.country_id
LEFT JOIN `languages` ON languages.id = teams.language_id
LEFT JOIN `status` ON teams.status_id = status.id
JOIN `team_types` ON team_types.id = teams.type_id
JOIN `market_languages` ON teams.market_id = market_languages.market_id
WHERE (market_languages.is_default = 1)
AND (teams.status_id = 3)
GROUP BY `teams`.`id`
ORDER BY `teams`.`order_id` ASC, `teams`.`status_id` ASC
now I am obtaining specific columns and joining on a market and on the language but there is another table that relates markets and languages and which is the default language. unfortunately the it is saying that both languages are default where in the db it is clearly just 1 language default for that market.