Answer the question
In order to leave comments, you need to log in
Getting a parameter when creating a MySQL query
For example, there is an
INSERT INTO query jos_vm_category (category_id, vendor_id,category_name,category_description,category_thumb_image`, `category_full_image`, `category_publish) VALUES (NULL, '0', 'Product Category', 'Description Product Category', 'Image', ' full picture', NULL);
in this case, the category_id parameter is not passed, but generated automatically.
How to get this category_id when inserting , or only through SELECT ?
Answer the question
In order to leave comments, you need to log in
in fact, there are several ways to get an identifier, both before and after the insert.
Before:
1) SELECT MAX( category_id ) + 1 FROM jos_vm_category; - before insertion
2) make a trigger for insert and define the following identifier in the trigger
After:
1) PHP: int mysql_insert_id ([ resource $link_identifier ] ) link
2) mySQL: LAST_INSERT_ID(), LAST_INSERT_ID(expr) link
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question