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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:02:13+00:00 2026-06-03T11:02:13+00:00

I am trying to syphon data over from one table to another. The problem

  • 0

I am trying to “syphon” data over from one table to another. The problem I run into is that some of the data which is going in the new table is static, other data is being copied from an existing table. Let me start by showing the query I was trying to run:

INSERT INTO current_cart 
    (cart_ID, 
    cart_PO, 
    cart_user, 
    cart_date, 
    cart_qty, 
    cart_sku, 
    cart_description, 
    cart_price, 
    cart_linetotal) 
VALUES 
    ('$cartID', 
    '$poNumberNew', 
    '$email', 
    '$lineDate',
SELECT 
    orderdetail_qty, 
    orderdetail_sku, 
    orderdetail_description, 
    orderdetail_price, 
    orderdetail_linetotal
FROM orderdetail
WHERE orderdetail_custemail = $email AND orderdetail_po = $poNumber)

Obviously, all the PHP variables are declared beforehand. Essentially what I have running is a shopping cart. This query would take the items from a previous order and enter them in a new shopping cart so our customer can start a new order based on a previous order.

The problem I run into is how to insert records into a table when some of the data for the record is static (cartID, poNumberNew, email and lineDate) and other information is coming out of a different table? I am hoping I can do this without creating a loop to repeat a query for however many items there were in the order the customer is duplicating… I think that would bog down our site significantly.

I’ve seen a myriad of awesome answers on many other web dev questions I’ve had in the past, I’m hoping the stackoverflow community can help me out here…

Thanks!

  • 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-03T11:02:15+00:00Added an answer on June 3, 2026 at 11:02 am

    in a SELECT statement, you can have a column that returns an constant. For example,

    INSERT INTO current_cart 
        (cart_ID, 
        cart_PO, 
        cart_user, 
        cart_date, 
        cart_qty, 
        cart_sku, 
        cart_description, 
        cart_price, 
        cart_linetotal) 
    
    SELECT 
        '$cartID', 
        '$poNumberNew', 
        '$email', 
        '$lineDate',
        orderdetail_qty, 
        orderdetail_sku, 
        orderdetail_description, 
        orderdetail_price, 
        orderdetail_linetotal
    FROM orderdetail
    WHERE orderdetail_custemail = $email AND orderdetail_po = $poNumber)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to read in some information from the google maps api into my application
Trying to match this data, that is contained in one string: vsan 1 interfaces:
Trying to reproduce the problem from this question , I've found I can't plot
Trying to insert data in database from edittext in android but data is not
Trying to create an Oracle trigger that runs after a table is updated in
Trying to implement a MSMQ-backed WCF PubSub. I understand that net.msmq is one-way; however
Trying to find some simple SQL Server PIVOT examples. Most of the examples that
Trying to solve some queries from sql zoo to practice sql skills I have
Trying to run RabbitMQ on VPS with Ubuntu 10.04. Doing everything like usual: added
Trying to run the following: JS: $('#my-modal').modal(); markup: <img src=\Images\Browser\file_types\d8d74cae-2186-42ad-a932-3aa4b75e0f12.png title=name: a3 onclick=Attachment_onClick( bfa9ec7e-d781-4523-a4ee-dd587f699c18)=

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.