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 9206105
In Process

The Archive Base Latest Questions

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

I have a big query with a lot of inner join inside in a

  • 0

I have a big query with a lot of inner join inside in a page on my website.
I want to apply for some left outer join limit 1 but if I put it into the sql give me errors.

This is a small part of my query isn’t total, this query is only a part and ISN’T FINISH:

SELECT * FROM products 
               LEFT OUTER JOIN  (origins 
                        LEFT OUTER JOIN  origin_aliases ON origin_aliases.origin_id = origins.id 
                        AND origin_aliases.language = '$lang'
                        LEFT OUTER JOIN  (diets LEFT OUTER JOIN  diet_aliases ON diet_aliases.diet_id = diets.id AND diet_aliases.language = '$lang') 
                        ON origins.diet_id = diets.id) 
                ON products.origin_id = origins.id
                LEFT OUTER JOIN  (product_aliases 
                        LEFT OUTER JOIN  (users as users1
                            LEFT OUTER JOIN  profiles as profiles1 ON profiles1.user_id = users1.id
                            LEFT OUTER JOIN  user_options as user_options1 ON user_options1.user_id = users1.id 
                            LEFT OUTER JOIN  avatars as avatars1 ON avatars1.user_id = users1.id
                        ) 
                        ON  product_aliases.user_id =users1.id
                        LEFT OUTER JOIN  (users as users2
                            LEFT OUTER JOIN  profiles as profiles2 ON profiles2.user_id = users2.id
                            LEFT OUTER JOIN  user_options as user_options2 ON user_options2.user_id = users2.id
                            LEFT OUTER JOIN  avatars as avatars2 ON avatars2.user_id = users2.id 
                        )  
                        ON  product_aliases.edit_user_id = users2.id)
                ON product_aliases.product_id = products.id  

…..

For example I want to apply limit 1 in the left outer join in origins after ON 'products.origin_id'='origins.id' is possible? How can I do this?
I have tried to put after the on condition limit 1 but give me an error

Syntax error or access violation: 1064 You have an error in your SQL
syntax; check the manual that corresponds to your MySQL server version
for the right syntax

  • 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:06:21+00:00Added an answer on June 18, 2026 at 12:06 am

    As written, your example is full or errors. Your derived tables do not have SELECT clauses, you have quoted the table and column references, and it’s not clear if names like origins and origin_aliases are tables or aliases. Those are your syntax errors.

    Once you correct those, you can add the LIMIT expression to the entire query or to any of the derived tables. Here is my best guess:

    SELECT * 
    FROM products 
    LEFT OUTER JOIN ( 
       select *
       from   origins 
       LEFT OUTER JOIN origin_aliases 
       ON     origin_aliases.origin_id = origins.id 
          AND origin_aliases.language = '$lang' 
       LEFT OUTER JOIN ( 
          select *
          from   diets 
          LEFT OUTER JOIN  diet_aliases 
          ON     diet_aliases.diet_id = diets.id 
             AND diet_aliases.language = '$lang'
          ) d
       ON origins.diet_id=d.id
    
       LIMIT 1
       ) a
    ON products.origin_id=a.id
    

    I choose to use two table aliases (a and b). And I’m assuming that origins, origin_aliases, and diets are tables. Note you should not use SELECT *; provide the column names you want from each derived table as well as in your main SELECT clause.

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

Sidebar

Related Questions

i have a big query (in my query builder) and a lot of left
I have big table with 22 millions records. I want to execute next query:
I have big set of urls and I want to implement an autocompletion. I
I have a query where I am doing an Order by inside of a
I have this big function that gets a lot of different data and insert
I have an application where I create a big SQL query dynamically for SQL
I have a big mysql query which needs to trawl through 4 tables to
I have a big table with 10M rows. And I need to get some
I have a big sql file that contains a lot of 'create table ...'
I have a very big table with a lot of rows and a lot

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.