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

  • Home
  • SEARCH
  • 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 8133855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:47:22+00:00 2026-06-06T09:47:22+00:00

I have table table1 **************************** id | start_date | end_date 1 30/06/2012 01/01/9999 When

  • 0

I have table

table1
****************************
id | start_date | end_date  
1    30/06/2012   01/01/9999

When I insert a new row

id | start_date | end_date
1    30/06/2012   26/06/2012 <- Now it is the start date of the next row2
2    26/06/2012   01/01/9999

The start date of insert row will became the end date of previous row and so on.

 $sql = "INSERT INTO 
                    table1(cate_id,task_id,obj,end_date,start_date,line)
                    SELECT 
                        $cate_id ,
                        $task_id,
                        $obj,
                        '2011-02-28', -> this what I am trying to do
                        '9999-01-01', -> this what I am trying to do
                        line1 
                    FROM 
                        line_task
                    WHERE 
                         line_task_id = (
                                            SELECT 
                                                line_task_id 
                                            FROM 
                                                task 
                                            WHERE 
                                                task_id = 2
                                           )";

When I tried something like this:

insert into table1(cate_id,task_id,obj, start_date, end_date,line) 
values (4,3,23, (Select max(end_date) from table1),end_date,'value_line');

I got message :

  Error code 1093, SQL state HY000: You can't specify target table 'table1' for update     in FROM clause
Line 1, column 1

Execution finished after 0 s, 1 error(s) occurred

Could told me how can I do this with mysql?
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-06T09:47:24+00:00Added an answer on June 6, 2026 at 9:47 am

    Try this::

      Set @max_date = Select max(end_date) from table;
    
        Insert into table(id, start_date, end_date) values (id, @max_date ,end_date);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table maintaining record of all reservations made. Now the start date
I have a table in database which contains start date and end date. Now
I have a table which stores in each row a meeting with start date/time
I have a table with the following columns: ref_year, ref_no, inv_id, start_date, end_date The
I have a table tbl_charge id hotel_id start_date end_date charge_per_day ( in $) 1
I have a table with data such as below Group Start Date End Date
Let's say I have the following table: Employee name start_date end_date John 2009-10-10 2009-12-31
i have this table +------+--------+-------------------------+ | id | amount | start_date | end_date |
I have a table of the sort: USER | PLAN | START_DATE | END_DATE
I have a table that has a START_DATE and an END_DATE column. I want

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.