Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

How to get the next id in MySQL to insert it in the table

INSERT INTO payments (date, item, method, payment_code)

VALUES (NOW(), '1 Month', 'paypal', CONCAT("sahf4d2fdd45", id))

1 Answer

0 votes
by (40.7k points)

Try using the below code:

SELECT AUTO_INCREMENT

FROM information_schema.tables

WHERE table_name = 'table_name'

AND table_schema = DATABASE( ) ;

But if you don't want to use information_schema then use this

SHOW TABLE STATUS LIKE 'table_name'

Related questions

0 votes
1 answer
asked Jul 18, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 12, 2019 in SQL by Tech4ever (20.3k points)

Browse Categories

...