Jump to content
  • 0

определение auto_increment атрибута


CoDy
 Share

Question

Привет форумчане!!! Нужна помощь.

Есть таблица в MySql базе.

В таблице ключевое поле задано как автоинкремент

CREATE TABLE `ab_contact` (

`<b>contact_id</b>` smallint(6) NOT NULL <b>auto_increment</b>,

`user_id` smallint(6) NOT NULL,

`contact_title` varchar(100) NOT NULL,

PRIMARY KEY (`contact_id`)

) TYPE=MyISAM AUTO_INCREMENT=1 ;

при добавлении строки в таблицу значение ключевого поля увеличится.

INSERT INTO `ab_user` ( `user_id` , `user_login` , `user_password` )

VALUES (

'', '1', '1'

);

как можно определить какое значение было занесено в user_id при выполнении этого инсерта?

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0
CREATE TABLE `ab_contact` (

`contact_id` smallint(6) NOT NULL auto_increment,

`user_id` smallint(6) NOT NULL,

`contact_title` varchar(100) NOT NULL,

PRIMARY KEY (`contact_id`)

) TYPE=MyISAM AUTO_INCREMENT=1 ;

при добавлении строки в таблицу значение ключевого поля увеличится.

INSERT INTO `ab_user` ( `user_id` , `user_login` , `user_password` )

VALUES (

'', '1', '1'

);

Классный пример привёл ;) Edited by Int
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy