www.webdeveloper.com
Results 1 to 2 of 2

Thread: Help with mysql insert

Hybrid View

  1. #1
    Join Date
    Oct 2012
    Posts
    1

    Help with mysql insert

    Hi all,

    I have a table called users and another called temp_user_id.

    Table temp_user_id has 5 columns:

    Column Name Type Auto-Increment

    menu_order_id int(11) Yes
    user_id int(11)
    menu_id int(11)
    is_active tinyint(1))
    ordering mediumint(8)

    I want to select all user_id from the users table and insert them into the table temp_user_id with the values below in the other columns. The expected values are below:

    menu_order_id Auto-Incremented ID
    user_id user_id from users table
    menu_id 10
    is_active 1
    ordering 100

    Can anyone assist?

  2. #2
    Join Date
    Sep 2012
    Posts
    14
    Hi, I have not tested this, but this should do the trick for you.

    PHP Code:
    $sql 'INSERT INTO temp_user_id (user_id, menu_id, is_active, ordering) SELECT user_id, menu_id, is_active, ordering from USER_ID';
    MYSQL_QUERY($sql); 
    This is of course if i understand you correctly, you basically want to copy information from one table to another?

    Michael

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles