• I’ve got a buddypress installation on a pre-existing wordpress site. There are about 400 users and I need each to be pre-joined to a couple of groups. I can see in the database where these records need to go, and what data items are needed but I really don’t want to manually input the records!

    What I want is to create a new row in a given table for every user ID. The user ID needs to populate one field while the other fields are set.

    Can anyone out there tell me what I should do? I use the free tools out of MySQL to administer the database.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Need more information. Before anyone can try to show the sql to do what you want, you need to supply the names of all tables involved, the data names of non-wp tables, and a sample of the data that you want a person to have.

    Thread Starter nathan12343

    (@nathan12343)

    Hi, I was after some generic pointers of how to do it but specifically:

    For each ID from the table parents_users in the schema called mysite create a row in the table called parents_bp_group_members.

    In this table there are the following fields:

    id – primary key
    group_id – which should read 1
    user_id – which should take the value in id from ‘mysite’.’parents_users’
    inviter_id – should read 0
    is_admin – should read 0
    is_mod – should read 0
    user_title – should be blank
    date_modified – full date and time value can be anything in form 2010-10-05 13:25:44
    comments – should be blank
    is_confirmed – should read 1
    is_banned – should read 0
    invite_sent – should read 0

    This should be close to what you want. I have no means to test it, so watch for typos.

    INSERT INTO parents_bp_group_members
    (id, group_id, user_id, inviter_id, is_admin, is_mod, user_title, date_modified, comments, is_confirmed, is_banned, invite_sent)
    SELECT 0, 1, parents_users.id, 0, 0, 0, '', NOW(), '' 1, 0, 0
    FROM parents_users
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Creating rows in MySQL tables’ is closed to new replies.