D
D
Dmitry2019-04-08 13:26:59
SQL
Dmitry, 2019-04-08 13:26:59

How to specify id with autoincrement type in sql query?

Hello
, id is int(10) autoincrement unsigned
When adding a comment to a table with id = 2, everything is ok

INSERT INTO `product_comments`(`id`, `product_slug`, `product_id`, `user_id`, `created_at`, `updated_at`, `content`) VALUES (2,'крем-для-рук-и-ногтей',1,2,'2019-04-08 13:25:31.000000','2019-04-08 13:25:31.000000','Крем вообще супер.')

What should the request look like so that it increases automatically?
Requests of this kind do not pass
INSERT INTO `product_comments`(`id`, `product_slug`, `product_id`, `user_id`, `created_at`, `updated_at`, `content`) VALUES ( ,'крем-для-рук-и-ногтей',1,2,'2019-04-08 13:25:31.000000','2019-04-08 13:25:31.000000','Крем вообще супер.')

INSERT INTO `product_comments`(`id`, `product_slug`, `product_id`, `user_id`, `created_at`, `updated_at`, `content`) VALUES ('', 'крем-для-рук-и-ногтей',1,2,'2019-04-08 13:25:31.000000','2019-04-08 13:25:31.000000','Крем вообще супер.')

Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nozzy, 2019-04-08
@ddimonn8080

Remove id from request, autoincrement will be added automatically

INSERT INTO `product_comments` (`product_slug`, `product_id`, `user_id`, `created_at`, `updated_at`, `content`) VALUES ('крем-для-рук-и-ногтей',1,2,'2019-04-08 13:25:31.000000','2019-04-08 13:25:31.000000','Крем вообще супер.')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question