Ho do I select randum values from table-1 and insert into table-2 with current date??

Discussion in 'MySQL' started by triogrid, May 16, 2010.

  1. #1
    I have found myself a solution so removing the same from here.

    thanks
     
    Last edited: May 16, 2010
    triogrid, May 16, 2010 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    You need to know the column names but something like this should work.

    INSERT INTO table_2 (column1, column2, date_column) SELECT column1, column2, NOW() FROM table_1 ORDER BY rand() LIMIT 1;
     
    jestep, May 16, 2010 IP