query to get the next ID:
SELECT AUTO_INCREMENT
FROM information_schema.tables
WHERE table_name = 'nome_da_tabela'
AND table_schema = DATABASE();
Or one of these:
SHOW TABLE STATUS FROM nome_da_base_de_dados LIKE 'nome_da_tabela';
SHOW TABLE STATUS FROM nome_da_base_de_dados WHERE Name='nome_da_tabela';
Note that these queries are very specific, probably only serving in MySQL itself. The option with SHOW TABLE STATUS
returns multiple columns , including the next auto-increment.
An alternative would be to give an UPDATE on the line you just inserted, using the column id
+ 1, which gives you the same as last_insert_id()
.
Anyway, it is worth saying that probably this solution you are looking for sooner or later will give you trouble, either by insertion failure, two users trying to insert almost at the same time, or even the simple mismatch of data in the time for some removal.
I can not say this, because you did not give details of what you are doing, but from the initial question, I have a slight feeling that, whatever it is you're trying to do, maybe you have other ways to be resolved.