MYSQL: How can I create a new row and get the new id without inserting data? -
Normally I get a new ID after entering some data and it creates a new line and returns the new ID . But if I do not want to include any data, I just want to create a new ID and want to get a new ID ... How can I do this?
Update:
Okay this is my problem, the table I wanted to do it in 1 id column only Why? I will explain (we will try) I have another table where each line has its own unique ID variation_id (auto-ink), but each line needs to be tied from the same table to the other ranks. I have another column which is called group_id, I can not be auto ink because it needs to be displayed multiple times, what does it mean to say, what kind of changes should be grouped together. So I have to create a second table with Group_ID as the primary key and auto-ink, so that whenever I need a new group, I can use it to generate new group_id. I think I'm going wrong about it ... so what should I do?
Here's an example:
create table X (id int Primary key AUTO_INCREMENT); Then you can "feed" your table:
Enter the values in the (id) values (zero); SELECT LAST_INSERT_ID (); Check this Bela:
Hope it helps!
Тарас Лукавий has another question and the answer is:
Create table X (ID int primary key AUTO_INCREMENT, timing timestamp);
Then you "feed" data with:
INSERT X (id, time) value (NULL, now ()); SELECT LAST_INSERT_ID ();
Now, let's check this:
SELECT * FROM X
You will see each row automatically ID and timestamp
Check this Bela:
Hope it helps!
Comments
Post a Comment