I have a table with quiz questions. Each question has a unique ID, based on
an auto_increment field.
Now I've discovered that with deleting rows from the table the deleted ID's
are not reissued. Makes sense, just thought of that a bit late.
How can I simply re-index or update or how one would call it, the columns
holding the ID numbers ? Is there a ready-made mysql command or do I have to
load all rows in PHP and modify where necessary ?
TIA
Pjotr 4 1960
*** Pjotr Wedersteers wrote/escribió (Mon, 30 Aug 2004 10:47:43 +0200): I have a table with quiz questions. Each question has a unique ID, based on an auto_increment field. Now I've discovered that with deleting rows from the table the deleted ID's are not reissued. Makes sense, just thought of that a bit late.
How can I simply re-index or update or how one would call it, the columns holding the ID numbers ? Is there a ready-made mysql command or do I have to load all rows in PHP and modify where necessary ?
I wouldn't play with that. If auto-generated IDs are not valid for you,
just quite using them. You can make your column UNIQUE to prevent
duplicates and assign your own IDs from the very beginning.
--
-- Álvaro G. Vicario - Burgos, Spain
-- Questions sent to my mailbox will be billed ;-)
--
There is no automatic way to rebuild a table and have the missing
auto-increment values used up. This could cause a serious problem if one of
these primary keys was a foreign key on another table.
Why do you need a deleted row to be re-used? What problem does it cause to
have a missing id number?
--
Tony Marston http://www.tonymarston.net
"Pjotr Wedersteers" <x3****@westert erp.com> wrote in message
news:41******** *************** @news.xs4all.nl ... I have a table with quiz questions. Each question has a unique ID, based on an auto_increment field. Now I've discovered that with deleting rows from the table the deleted ID's are not reissued. Makes sense, just thought of that a bit late.
How can I simply re-index or update or how one would call it, the columns holding the ID numbers ? Is there a ready-made mysql command or do I have to load all rows in PHP and modify where necessary ?
TIA Pjotr
Tony Marston wrote: There is no automatic way to rebuild a table and have the missing auto-increment values used up. This could cause a serious problem if one of these primary keys was a foreign key on another table.
Why do you need a deleted row to be re-used? What problem does it cause to have a missing id number?
"Pjotr Wedersteers" <x3****@westert erp.com> wrote in message news:41******** *************** @news.xs4all.nl ... I have a table with quiz questions. Each question has a unique ID, based on an auto_increment field. Now I've discovered that with deleting rows from the table the deleted ID's are not reissued. Makes sense, just thought of that a bit late.
How can I simply re-index or update or how one would call it, the columns holding the ID numbers ? Is there a ready-made mysql command or do I have to load all rows in PHP and modify where necessary ?
TIA Pjotr
I intended on using a random ID number 1..num_rows and retrieving the
question with that ID from the table. I will now have to do an additional
check to see whether mysql_reult for that random number holds a row of data
indeed. No biggy in this case. I think in retrospect in this case
auto_increment just wasn't the field to use. I had better used a UNIQUE id
field I numbered myself.
Thanks both for the advise. I somehow already figured tampering with
auto-increment data wasn't a wise plan.
Pjotr
In article <41************ *********@news. xs4all.nl>, Pjotr Wedersteers wrote: I intended on using a random ID number 1..num_rows and retrieving the question with that ID from the table. I will now have to do an additional check to see whether mysql_reult for that random number holds a row of data indeed. No biggy in this case. I think in retrospect in this case auto_increment just wasn't the field to use. I had better used a UNIQUE id field I numbered myself.
If you are using MySQL:
SELECT * FROM table ORDER BY RAND();
--
Tim Van Wassenhove <http://home.mysth.be/~timvw> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jason |
last post by:
Let's say I have an html form with 20 or 30 fields in it. The form
submits the fields via POST to a php page which updates a table in a
database with the $_POST vars. Which makes more sense?
1) simply UPDATING the values for all fields in the table, whether or
not any particular field has actually changed
2) running a second SELECT statement and comparing the $_POST vars to
the returned values, and only UPDATING those that have...
|
by: Geoff |
last post by:
Hi
I'm hoping somebody can help me with the following problem that has occurred
to me.
Suppose I have two tables in an SQL Server database. Let's call these tables
A and B. Assume that A has two fields: a primary key and another holding a
string. In table B there are three fields: a primary key, a foreign key
(which links to the primary key in A) and other field holding a string.
|
by: bill |
last post by:
In an application I am writing the user can define a series of
steps to be followed. I save them in a sql database using the
field "order" (a smallint) as the primary key.
(there are in the range of 20 steps)
On the admin page the steps are listed, in "order" order and the
user can create new steps and assign an order and all is well.
The problem may come in using a renumber function which should
take the steps in their current order...
|
by: Siong.Ong |
last post by:
Dear all,
my PHP aims to update a MySQL database by selecting record
one by one and modify then save.
Here are my PHP, but I found that it doesnt work as it supposed to be,
for example, when Record (i) is shown and modified, the change will
come to Record (i+1).
Can anyone provide suggestion?
thanks.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |