Connecting Tech Pros Worldwide Help | Site Map

Merge two table together

Newbie
 
Join Date: Nov 2008
Location: Ausitn, TX
Posts: 2
#1: Dec 23 '08
Okay, this is what I have so far.

I was trying to do a Union Query, this is the SQL information I have.
Expand|Select|Wrap|Line Numbers
  1. ELECT TRANSFORMERS.CoNo,
  2.        TRANSFORMERS.SerialNo,
  3.        TRANSFORMERS.KVA,
  4.        TRANSFORMERS.Mfg,
  5.        TRANSFORMERS.PriVoltsHigh,
  6.        TRANSFORMERS.PriVoltsLow,
  7.        TRANSFORMERS.SecVoltsHight,
  8.        TRANSFORMERS.SecVoltsLow
  9. FROM TRANSFORMERS INNER
  10. UNION ALL
  11. SELECT TRANSFORMERS.CoNo,
  12.        TRANSFORMERS.SerialNo,
  13.        TRANSFORMERS.KVA,
  14.        TRANSFORMERS.Mfg,
  15.        TRANSFORMERS.PriVoltsHigh,
  16.        TRANSFORMERS.PriVoltsLow,
  17.        TRANSFORMERS.SecVoltsHight,
  18.        TRANSFORMERS.SecVoltsLow
  19. FROM TRANSFORMERSNew;
I keep getting an error "Syntax error in JOIN operation"...did I miss something?
Help...
Member
 
Join Date: Oct 2008
Posts: 59
#2: Dec 23 '08

re: Merge two table together


Could it be that the first word in your SQL statement says ELECT when it should say SELECT?
Expert
 
Join Date: Jul 2008
Location: Maryland
Posts: 1,163
#3: Dec 23 '08

re: Merge two table together


INNER is the keyword for a type of JOIN. I've never heard of an INNER UNION ALL.
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,714
#4: Dec 23 '08

re: Merge two table together


Karyna,

Notice I reformatted the SQL code for you as well as adding the [ CODE ] tags. I wonder how so many members seem to expect us to be able to read their SQL when they just dump it in a mess without any sort of formatting. This takes no special expertise, simply a little time and effort. I don't mean to bust your chops on this, but I really just don't get how this happens so often. As this is your first post I won't make a big deal out of it (in truth I want to leave it for others to find as they search through, rather than direct it specifically at yourself).

If you re-examine it now, you will see a number of mistakes (especially if I point them out to you) :
  1. As mentioned before, the first character is missing from the SELECT on line #1.
  2. On line #9 there is the remnants of an INNER JOIN statement. I guess someone decided to use the UNION ALL instead but failed to clear away the INNER JOIN fully.
  3. The second SELECT query in the UNION (starting at line #11) refers to the wrong table. All the lines from #11 to #18 should be referring to TRANSFORMERSNew rather than TRANSFORMERS.

Welcome to Bytes!
Newbie
 
Join Date: Nov 2008
Location: Ausitn, TX
Posts: 2
#5: Dec 24 '08

re: Merge two table together


I will make sure to put code in a proper format.

I do have the "S" in the code...but I did not realize that INNER was not needed.

Is there a specific book on queries in Access, that anyone can recommend.

Thank you to all who responded.

Merry Christmas!
MindBender77's Avatar
Familiar Sight
 
Join Date: Jul 2007
Location: Pittsburgh,Pa USA
Posts: 232
#6: Dec 24 '08

re: Merge two table together


Quote:

Originally Posted by karynaweiss View Post

Is there a specific book on queries in Access, that anyone can recommend.

I would advise using Google to assist you. There is a plethora of information out there. Just search for: "Access Query Basics" for example.

Here is one to get started.
Query Basics

Hope this helps,
Bender
Reply