Your question was can i get the just inserted content by the INSERT INTO query?

|
thanosphan 2021-10-17 23:45:01
Qlagh 2021-10-16 20:54:26
how can i count how many row i added into my table?
i may delete all of them
i just want to know many ive added in the past!

If you have a column that has an autoincrement sequence, you could use the max of it

MasterZiv 2021-10-18 06:56:27
thanosphan 2021-10-17 23:45:01
If you have a column that has an autoincrement sequence, you could use the max of it

Unreliable. Auto increment counter can be reset.

OnlySmene 2021-10-18 09:03:46
can i get the just inserted content by the INSERT INTO query?
MasterZiv 2021-10-18 09:10:53
OnlySmene 2021-10-18 09:03:46
can i get the just inserted content by the INSERT INTO query?

Yes use
Insert…
Returning…

MasterZiv 2021-10-18 09:13:23
MasterZiv 2021-10-18 09:10:53
Yes use
Insert…
Returning…

Sorry, no, this is not possible this is from PG

MasterZiv 2021-10-18 09:14:21
OnlySmene 2021-10-18 09:03:46
can i get the just inserted content by the INSERT INTO query?

You can get the id of new row and select it

OnlySmene 2021-10-18 09:30:54
MasterZiv 2021-10-18 09:10:53
Yes use
Insert…
Returning…

ok, thanks!

MasterZiv 2021-10-18 10:41:55
OnlySmene 2021-10-18 09:30:54
ok, thanks!

Read next message

thanosphan 2021-10-18 17:54:13
MasterZiv 2021-10-18 06:56:27
Unreliable. Auto increment counter can be reset.

Yes. And it needn’t always increment by 1

ssssss 2021-10-19 12:13:15
Is there any possibility to recover the data after truncate use without backup?
svart 2021-10-19 17:19:14
ssssss 2021-10-19 12:13:15
Is there any possibility to recover the data after truncate use without backup?

Assuming that you do not have a delayed replica the answer is “no”. If you would use the delete statement you could recover from binary logs but it is not your case

OnlySmene 2021-10-19 19:42:07
@MasterZiv RETURNING is not working in MySQL 8.0.
It says: you have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘RETURNING sess_id’ at line 1
MasterZiv 2021-10-19 19:42:41
OnlySmene 2021-10-19 19:42:07
@MasterZiv RETURNING is not working in MySQL 8.0.
It says: you have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘RETURNING sess_id’ at line 1

Yes, that is why I told READ THE NEXT MESSAGE!

OnlySmene 2021-10-19 19:43:00
MasterZiv 2021-10-19 19:42:41
Yes, that is why I told READ THE NEXT MESSAGE!

I am not using any numeric id, thats why i cannot follow that way

MasterZiv 2021-10-19 19:43:46
OnlySmene 2021-10-19 19:43:00
I am not using any numeric id, thats why i cannot follow that way

You must have some primary key, don’t you have?

OnlySmene 2021-10-19 19:43:58
MasterZiv 2021-10-19 19:43:46
You must have some primary key, don’t you have?

I’ve not, is that a good practice?

MasterZiv 2021-10-19 19:44:47
OnlySmene 2021-10-19 19:43:58
I’ve not, is that a good practice?

It is not good practice, this is the must !

OnlySmene 2021-10-19 19:44:55
MasterZiv 2021-10-19 19:44:47
It is not good practice, this is the must !

why, if may I ask?

MasterZiv 2021-10-19 19:45:33
OnlySmene 2021-10-19 19:44:55
why, if may I ask?

because rows in each table must be identifiable and distinct

OnlySmene 2021-10-19 19:45:59
MasterZiv 2021-10-19 19:45:33
because rows in each table must be identifiable and distinct

ah ok, im creating an authentication system, and im generating some uuid4 id. Can I use that value as primary key?

MasterZiv 2021-10-19 19:46:13
Or otherwise you will not be able to work with this table data
MasterZiv 2021-10-19 19:46:47
OnlySmene 2021-10-19 19:45:59
ah ok, im creating an authentication system, and im generating some uuid4 id. Can I use that value as primary key?

Yes, if it is unique for each row…

OnlySmene 2021-10-19 19:47:02
MasterZiv 2021-10-19 19:46:47
Yes, if it is unique for each row…

well, and what changes if I add PRIMARY KEY statement or I dont

MasterZiv 2021-10-19 19:49:37
OnlySmene 2021-10-19 19:47:02
well, and what changes if I add PRIMARY KEY statement or I dont

Your question was can i get the just inserted content by the INSERT INTO query?

And if you have PK, you must know its value before or after the insert, and if so,
you can manually select the inserted row by PK value.

OnlySmene 2021-10-19 19:50:08
MasterZiv 2021-10-19 19:49:37
Your question was can i get the just inserted content by the INSERT INTO query?

And if you have PK, you must know its value before or after the insert, and if so,
you can manually select the inserted row by PK value.

oh well! so thats used for queries

MasterZiv 2021-10-19 19:52:58
OnlySmene 2021-10-19 19:50:08
oh well! so thats used for queries

yes.

OnlySmene 2021-10-19 19:53:36
and how do I get the record by id using insert into?
cris_highlight_bot 2021-10-19 20:01:37
MasterZiv 2021-10-19 20:01:37
No, you do INSERT, and then you get PK value back (or you know it already if it is not a serial key), and then you issue

SELECT * from thetable where pkfield = :newid

mysql_en-13523.jpg

MasterZiv 2021-10-19 20:01:37
OnlySmene 2021-10-19 19:53:36
and how do I get the record by id using insert into?

No, you do INSERT, and then you get PK value back (or you know it already if it is not a serial key), and then you issue

SELECT * from thetable where pkfield = :newid

OnlySmene 2021-10-19 20:02:16
ok, ty
2021-10-21 18:15:29
I need some advice with storing values in temporary data tables
MasterZiv 2021-10-21 19:18:39
2021-10-21 18:15:29
I need some advice with storing values in temporary data tables

Unless you ask a question it cannot be answered

2021-10-22 11:04:27
I want to store following value into a multiple variable
2021-10-22 11:04:43
And then use it to get users post
2021-10-22 11:05:17
I’m trying to do something similar with JavaScript but is a bit complicated
|