Thanks a lot all of you for your help :) Am thinking to make the default value of membership_id equal to id and by that duplicates will never occurred and also am not need to remove id column.
Thanks again for ur help :) On Apr 4, 3:44 pm, Ross Peoples <ross.peop...@gmail.com> wrote: > Massimo's idea would work, but the table would need to have "membership_id" > set up as an identity field. If your existing structure requires you to > manually fill in this value yourself, then you would have to do your inserts > manually using executesql: > > db.executesql("INSERT INTO member (membership_id, first_name) VALUES > ((SELECT MAX(membership_id) FROM member) + 1, 'bob')") > > This may not be the exact SQL you would use, but it gets my point across. > Also, you would not want to append the first_name value. You would want to > use executesql() placeholders to sanitize the data to prevent SQL injection. > > By doing the select in the same query as the insert, you can prevent > duplicate membership_id's from being generated.