Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 603809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:58:16+00:00 2026-05-13T16:58:16+00:00

So I am trying to return only the records that are set to default

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:58:17+00:00Added an answer on May 13, 2026 at 4:58 pm

    So after more tweeking I found my solution, initially I was doing the single join and hoping to get a good return on the language but but markets where wrong. So I did some searching on complex joins and I came to a good resource on on http://www.bryanwebconsulting.com/blog/ Outer Join on Multiple Fields.

    So after reading that I modded the sql as follows:

    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` 
    
    INNER 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 
    
    INNER JOIN `team_types` ON team_types.id = teams.type_id 
    
    INNER JOIN `market_languages` ON ( teams.language_id = market_languages.language_id 
    AND 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
    

    So yes you are able to do a more detailed join using the AND “blah blah ON (AND)”.

    Hope this helps others too and I think I could clean this up even more now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to craft a regex that only returns <link> tag hrefs Why does
im trying to return a string value from a method inside my script tag
I'm trying to return a dictionary from a function. I believe the function is
I'm trying to return a transparent GIF from an .aspx page for display within
I am trying to return an array Data Member from one smaller 2D Array
I am trying to return the result that I found in my query to
I'm trying to return a record from LINQ2SQL as a JsonResult to update my
I'm trying to return sequence.nextval to my program from a proc stored in a
I'm trying to return an iterator for a vector in a templated class (I'm
I am trying to return the physical file path of a database's mdf/ldf files.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.