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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:39:33+00:00 2026-06-08T19:39:33+00:00

I have two databases that I’m trying to transfer data between. I’m working on

  • 0

I have two databases that I’m trying to transfer data between.

I’m working on getting orders from one to the other right now but I’ve run into something that I can’t figure out the correct way to do it.

Here’s the query thus far…

INSERT INTO `NEWTEST`.`Order_LineDetails`

( OrderLineItem_ID, Customer_ID, Order_ID )

SELECT

OrderDetailID,

(    
SELECT o.CustomerID
FROM `OLDTEST`.`Order_Details` od
JOIN `OLDTEST`.`Orders` o ON  o.OrderID = od.OrderID
),

OrderID

FROM `OLDTEST`.`Order_Details`

This is returning an error of ‘#1242 – Subquery returns more than 1 row’.

The result I’m going for would be to get…

OLDTEST.Order_Details           -> NEWTEST.Order_LineDetails
OLDTEST.Order.CustomerID        -> NEWTEST.Customer_ID
OLDTEST.Order_Details.OrderID   -> NEWTEST.Order_ID

What am I missing?

:::::: EDIT :::::::

This is now correct and works fine.

SELECT

  od.OrderDetailID,
  o.CustomerID,
  od.OrderID

FROM `OrderProcessing`.`Order_Details` od

JOIN `OrderProcessing`.`Orders` o ON o.OrderID = od.OrderID

LIMIT 100
  • 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-08T19:39:34+00:00Added an answer on June 8, 2026 at 7:39 pm

    When you use a subquery in the SELECT clause as you did, it must return a single row, hence the error you’re getting.

    Actually you don’t seem to need the subquery here:

    INSERT INTO `NEWTEST`.`Order_LineDetails`
    SELECT
        od.OrderDetailID,
        o.CustomerID,
        od.OrderID
    FROM `OLDTEST`.`Order_Details` od
    JOIN `OLDTEST`.`Orders` o ON  o.OrderID = od.OrderID
    

    (Before running that, comment out the INSERT line to make sure it’s giving the results you expect).

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

Sidebar

Related Questions

I have two databases. I want to dump data from one table in 1st
I have two databases on one machine that also has two different sites running
I have two databases in SQL2k5: one that holds a large amount of static
I have two different DataContexts (SQL Databases) that have the same data, just with
I have two databases that are differently formatted. Each database contains person data such
I have two databases, one is an MS Access file, the other is a
I have two SQL Server 2005 databases, one is for development and the other
I have a query against two databases that I'm trying to execute. The first
In my project I currently have two databases, one that is named ASPNETDB.MDF and
I have a web application that uses two databases. DB1 Users perform their CRUD

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.