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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:56:23+00:00 2026-05-25T19:56:23+00:00

So, I get this error message: EDT ERROR: syntax error at or near union

  • 0

So, I get this error message:

EDT ERROR:  syntax error at or near "union" at character 436

The query in question is a large query that consists of 12 smaller queries all connected together with UNION ALL, and each small query has two inner join statements. So, something like:

SELECT table.someid as id
    ,table.lastname as name
    ,table2.groupname as groupname
    , 'Leads     ' as Type
from table 
inner join table3 on table3.specificid = table.someid
INNER JOIN table2 on table3.specificid=table2.groupid
where table3.deleted=0 
 and table.someid > 0
 and table2.groupid in ('2','3','4')
LIMIT 5 
UNION all 
query2....

Note that table2 and table3 are the same tables in each query, and the fields from table2 and table3 are also the same, I think.

Quick question (I am still kinda new to all this):
What does ‘Leads ‘ as Type mean? Unlike the other statements preceding an AS, this one isn’t written like table.something.
Quick edit question: What does table2.groupid in (‘2′,’3′,’4’) mean?

I checked each small query one by one, each one works and returns a result, though the results are always empty for some reason(this may or may not be dependent on the user logged in though, as some PHP code generated this query).

As for the results themselves, most of them look something like this (they are arranged horizontally though):

id(integer)
name (character varying(80))
groupname (character varying(100))
type (unknown)

The difference in the results are twofold:
1)Most of the results contain the same field names but quite a few of them have different field lengths. Like some will say character varying (80), while others will say character varying (100), please correct me if this is actually not field length.
2)2 of the queries contain different fields, but only the id field is different, and it’s probably because they don’t have the “as id” part.

I am not quite sure of what the requirements of UNION ALL are, but if I think, it is meant to only work if all the fields are the same, but if that funky number changes (the one in the brackets), then are the fields considered to be different even if they have the same name?

Also, what’s strange is that some of the queries returned the exact same fields, with the same field length, so I tried to UNION ALL only those queries, but no luck, still got a syntax error at UNION.

Another important thing I should mention is that the DB used to be MySQL, but we changed to PostGreSQL, so this bug might be a result of the change (i.e. code that might work in MySQL but not in PostGres).

Thanks for your time.

  • 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-25T19:56:24+00:00Added an answer on May 25, 2026 at 7:56 pm

    You can have only one “LIMIT xxx” clause. At the end of the query, and not before the UNION.

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

Sidebar

Related Questions

I get this error message Parse error: syntax error, unexpected $end in E:\xampp\htdocs\announcements\announcement.php on
Question: I get this error message: export: bad interpreter: No such file or directory
When invoking a query on the data service I get this error message inside
I get this error message: Parse error: syntax error, unexpected $end in C:\Users\Stacky\Desktop\xampp\htdocs\wweff\stackhelp.php on
I get this error message when installing SQL 2005 Analysis services. The cabinet File
I get this message when compiling C++ on gcc 4.3 error: ‘NULL’ was not
I get this error:- You have an error in your SQL syntax; check the
I get this error message in Eclipse: Access restriction: The type DirectoryWalker is not
I get this error message as I execute my JUnit tests: java.lang.OutOfMemoryError: GC overhead
I get this error message, what does it mean and how to fix it?

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.