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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:23:26+00:00 2026-06-17T04:23:26+00:00

I have a mysql table with members, about 1400 records, and I am going

  • 0

I have a mysql table with members, about 1400 records, and I am going to switch to a new membership software (amember v3 to amemberv4). The problem is that amember v4 is a whole new program so the database tables cannot have any missing records or it will reorder based on the primary key. For instance, membership ID in a members table which are associated with product IDs in a product table. There is a fact table that references this dimensions.

My problem is how to add in null records with a starting membership ID of those missing. For example the table begins with membership ID 4 instead of 1,2,3. I need help finding a solution to add these missing records based on membership ID’s that are missing. I did make a second table based on the first one (membersold, members) as I am sure I need to join them on each other to create an update statement to add those missing records. There are about 7 columns that will be just null values.

Any ideas?

  • 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-17T04:23:28+00:00Added an answer on June 17, 2026 at 4:23 am

    First of all: what both Jan Dvorak and Michael Berkowski said is absolutely true. Therefore, check carefully that you really need this hack, for chances are overwhelming that you don’t.

    But just in case, just for the heck of it, this inserts all IDs into a table – provided they are primary keys, and that they don’t already exist.

    Almost any other way is better (except maybe doing it by hand), but requires procedures in either MySQL or other languages.

    -- insert IDs from 1 to 1701, plus another field "otherfield" with value "othervalue"
    -- The maximum ID here is about 2400, but you said you needed at most 1400.
    -- And you can add 1000 instead of 1 to the value of 'id' and run it again
    -- to insert ids from 1000 to 2701 :-)
    
    INSERT IGNORE INTO yourtable
          (id, otherfield)
    SELECT id, 'othervalue'
    FROM (
        SELECT 1+a.x+b.x*7+c.x*49+d.x*343 AS id FROM
        ( SELECT 0 AS x UNION SELECT 1 UNION SELECT 2 UNION
          SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 ) AS a
        JOIN
        ( SELECT 0 AS x UNION SELECT 1 UNION SELECT 2 UNION
          SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 ) AS b
        JOIN
        ( SELECT 0 AS x UNION SELECT 1 UNION SELECT 2 UNION
          SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 ) AS c
        JOIN
        ( SELECT 0 AS x UNION SELECT 1 UNION SELECT 2 UNION
          SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 ) AS d
       ) AS generated
    WHERE generated.id < 1701;
    

    As I said, this is a very ugly way to do things.

    If you have any language available at all, you can generate the insert queries and run them, e.g. in bash:

    ( for id in $( seq 1 1400 ); do
        echo "INSERT IGNORE INTO mytable ( id, otherfield ) VALUES ( $id, 'hello' );"
    done ) | mysql databasename
    

    or in PHP, python, or Perl — you just generate a SQL INSERT statement of the form

    INSERT IGNORE INTO mytable ( id ) VALUES ( ... );
    

    and fill in the blanks with an incrementing counter, then send the statement to the database. The IGNORE will skip the values that are already there. How you fill the blanks depends on the language you choose. If you need to populate other fields, enter the names after id and their default values after the blanks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to ask something about query using mysql I have this table
I have about 28 million records to import into a mySql database. The record
I have a MySQL table ( members ) with six columns ( FirstName, LastName,
I have a mysql table storing members messages with 4 columns : message_id (primary
I have a members table in MySQL CREATE TABLE `members` ( `id` int(10) unsigned
I use mySQL and I have a members table with a BLOB 'contacts' field
I have mysql table that has a column that stores xml as a string.
I have MySQL InnoDB table utf-8 encoded. This table has only id and name
I have a MySQL table and would like to return the rows based on
I have a MySql table containing stock quotes (stock_symbol, quote_date, open_price, high_price, low_price, close_price)

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.