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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:45:42+00:00 2026-06-12T11:45:42+00:00

I am trying to merge some contents from table1 and table2 into another table3

  • 0

I am trying to merge some contents from table1 and table2 into another table3. I have the following query up and running in PostgreSQL:

CREATE TABLE table3 AS SELECT 
table1.orig_zon AS orig_zon,
table1.dest_zon AS dest_zon,
table1.same_zon AS same_zon,
table1.adjacent AS adjacent,
table1.distance AS distance,
table1.da_ivtt AS da_ivtt1,
table1.da_ovtt AS da_ovtt1,
table1.tr_avail AS tr_avail1,
table1.tr_ivtt AS tr_ivtt1,
table1.tr_ovtt AS tr_ovtt1,
table1.tr_cost AS tr_cost1,
table1.au_cost AS au_cost1,
table1.sr_ivtt AS sr_ivtt1,
table1.sr_cost AS sr_cost1,
table2.da_ivtt AS da_ivtt2,
table2.da_ovtt AS da_ovtt2,
table2.tr_avail AS tr_avail2,
table2.tr_ivtt AS tr_ivtt2,
table2.tr_ovtt AS tr_ovtt2,
table2.tr_cost AS tr_cost2,
table2.au_cost AS au_cost2,
table2.sr_ivtt AS sr_ivtt2,
table2.sr_cost AS sr_cost2,
FROM table1, table2
WHERE ((table1.orig_zon = table2.orig_zon)) AND ((table1.dest_zon = table2.dest_zon));

I have tested the query for a very small dummy dataset and the result is as desired. However my actual database is in SQLite and when I run this in the sqlite3 via Linux shell I get an error as:

Error: near "table1": syntax error

Can anyone point me to the modifications I need to make in order to make this work in SQLite? Thanks for the help!

Edit1:
After removing the trailing comma (see Craig’s comment below) the issue persists.

Edit2:
After playing around a bit I found the fix. Seems very silly but if I were to pass the contents of the query in a single line the statement works!

table2.sr_ivtt AS sr_ivtt2,
table2.sr_cost AS sr_cost2 FROM table1, table2 WHERE ((table1.orig_zon = table2.orig_zon)) AND ((table1.dest_zon = table2.dest_zon));

Oh! The bane of typecasting!!

  • 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-12T11:45:43+00:00Added an answer on June 12, 2026 at 11:45 am

    SQL doesn’t permit a trailing comma in the SELECT list.

    table2.sr_cost AS sr_cost2,
    FROM table1, table2
    

    should be:

    table2.sr_cost AS sr_cost2
    FROM table1, table2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to merge some columns from one table into a view that
I am trying to merge the data from two tables into one result but
Trying to merge some data that I have. The input would look like so:
I'm trying to merge two file that have the same structure, and some data
I get Already up-to-date messages when trying to merge one branch, 'feature_1', into another,
I'm working in Rails and Activerecord and trying to merge some data from related
I'm simply trying to merge 2 xml documents (adding nodes from one into the
I'm trying to merge two arrays that have some overlapping results and some that
I have the following 2 arrays that I'm trying to merge recursively so that
I am trying to merge some code behind code for .net that I found

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.