![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 267 Pomógł: 0 Dołączył: 11.09.2015 Ostrzeżenie: (0%) ![]() ![]() |
Mam tabele z auto increment na user_id:
CREATE TABLE IF NOT EXISTS `mgr_users` ( `users_id` int(11) NOT NULL AUTO_INCREMENT, `rank_id` int(11) NOT NULL, `users_login` text NOT NULL, `users_password` text NOT NULL, `users_active` int(11) NOT NULL, `users_online` int(11) NOT NULL, `users_zm` text NOT NULL, PRIMARY KEY (`users_id`), UNIQUE KEY `users_id` (`users_id`), KEY `rank_id` (`rank_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; Chce zrobic insert: string(256) "INSERT INTO mgr_users (`users_id`, `rank_id`, `users_login`, `users_password`, `users_active`) VALUES ('', '1', 'root', '7e31dee49d75c','1')" a jest blad zapytania, blad jest chyba dlatego ze usr id nie inkrementuje sie tylko dlaczego? to jest backup z bazy a wczesniej dzialalo. |
|
|
![]()
Post
#2
|
|
![]() Grupa: Zarejestrowani Postów: 1 707 Pomógł: 266 Dołączył: 3.07.2012 Skąd: Poznań Ostrzeżenie: (0%) ![]() ![]() |
Żeby wstawić wartość auto increment, trzeba dać NULL, a nie ''.
|
|
|
![]()
Post
#3
|
|
![]() Grupa: Zarejestrowani Postów: 207 Pomógł: 40 Dołączył: 2.06.2016 Skąd: Olsztyn Ostrzeżenie: (0%) ![]() ![]() |
W przypadku kiedy kolumna może być pusta, jest autoinkrementowalna, albo ma zdefiniowaną domyślną wartość możesz ją pominąć w zapytaniu np.
Kod INSERT INTO mgr_users (`rank_id`, `users_login`, `users_password`, `users_active`) VALUES ('1', 'root', '7e31dee49d75c','1')
-------------------- |
|
|
![]() ![]() |
![]() |
Aktualny czas: 22.08.2025 - 08:01 |