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

  • SEARCH
  • Home
  • 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 9205693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:00:39+00:00 2026-06-18T00:00:39+00:00

I need help writting a query. Using this schema as example: Table: A id

  • 0

I need help writting a query. Using this schema as example:

Table: A
id 1
id 2

Table: ALocalized
A_id 1, culture 1, name 'EN translation'
A_id 1, culture 2, name 'PT translation'
A_id 2, culture 1, name 'EN translation'

This is the schema i’m using to localize information. Each record on A has at least one related record on ALocalized, but there may be some rows who don’t have a localized record for certain cultures.

In this example, i want to query A and filter the ALocalized by culture 2. If culture 2 doesn’t exist, then return any other available.
The result should be:

A_id 1, culture 2, name 'PT translation'
A_id 2, culture 1, name 'EN translation'

I’ve tried to do this joining both tables, using an sub query but i think that my problem is in where clause.

where (ALocalized.culture = @cultureparameter OR ALocalized.culture = 1 OR ALocalized.culture = 2) limit 1

When @cultureparameter is 2 returns culture 1. It isn’t respecting the order of where clauses

How should i do this? I was trying to avoid the use of loops to check each A record for an existence of ALocalized.

Thanks in advance

  • 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-06-18T00:00:40+00:00Added an answer on June 18, 2026 at 12:00 am
    SELECT  a.*,
            COALESCE(b.culture, c.culture) Culture,
            COALESCE(b.Name, c.Name) Name
    FROM    tableA a
            LEFT JOIN   tableB b
                ON a.id = b.a_id AND
                    b.culture = 2
            LEFT JOIN   tableB c
                ON a.id = c.a_id AND
                    c.culture = 1
    
    • SQLFiddle Demo
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need help writing a script downloads data from google insight using c# this is
need help/guide for sql select query, I have 2 table stock and stock_history, in
Need help with a query that I wrote: I have three tables Company id
I need help re-factoring this legacy LINQ-SQL code which is generating around 100 update
I need some help writing an SQL query and I am not well versed
Hello I need help in writing a query. Below is my DB structure id
I need help with writing a query (mySQL) to Total number of users in
I need to write a query in sql server to data get like this.
I've a query that I need some help with - As part of a
Need help in writing the query to get the last month data as well

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.