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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:51:24+00:00 2026-06-08T18:51:24+00:00

I am attempting to copy data from specific columns in one row, and have

  • 0

I am attempting to copy data from specific columns in one row, and have it inserted/updated into another row, all in the same table. Each row already has an ID # (called order_no), so no auto-increment is needed.

I thought this would be pretty simple, but it’s just not working. my Table name is ‘orders’ and the columns are called ‘rn’ and ‘phone’ and the order_no are ‘416’ and ‘417’. I want rn, and phone from 416 to be inserted into the rn, and phone columns for 417.

I also have tried this query, attempting to copy just one record rn, with no success
and get error: #1248 – Every derived table must have its own alias

mysql_query("UPDATE orders
  SET rn =
     ( SELECT rn
        FROM ( SELECT rn
                FROM orders
                  WHERE order_no = 416
             ) 
 WHERE order_no = 417 ");

I have tried this with no success, and get Error #1136 – Column count doesn’t match value count at row 1

  mysql_query
(" INSERT INTO orders (rn, phone)
SELECT rn, phone, 416
from orders
WHERE order_no = 417 ");

Update. I also tried this query below, with just one field (rn) to no avail, and it throws error #1093 – You can’t specify target table ‘orders’ for update in FROM clause:

     mysql_query("UPDATE orders 
SET rn = (SELECT rn FROM orders WHERE order_no = '416') 
WHERE order_no = '417' ");

Any help or assistance is greatly appreciated. Thank you

  • 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-08T18:51:27+00:00Added an answer on June 8, 2026 at 6:51 pm

    You can modify your query

    mysql_query
    (" INSERT INTO orders (rn, phone)
    SELECT rn, phone, 416
    WHERE order_no = 417 ");
    

    to

    mysql_query
    (" INSERT INTO orders (rn, phone)
    SELECT rn, phone, 416
    from orders
    WHERE order_no = 417 ");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to use COPY FROM STDIN to import data into my table.
I'm attempting to copy data from three workbooks (one at a time) from the
I'm attempting to copy cells, one at a time, from an Excel 2003 (or
I am trying to copy some property values from one object to another (both
I'm attempting to copy the database located, as an example, in: /data/data/com.x.x.x/databases/mydb.db This works
I have a copy of codeigniter running. And I am now also attempting to
Attempting to use the data series from this example no longer passes the JSONLint
I'm attempting to recursively copy all files and directories and here is my class
I am attempting to copy an array in my ViewController to a Data storage
I have a DataTable that I am attempting to upload, but I run into

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.