我不想 the首,即使它打上了重复的入境错误!
I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...
我不想 the首,即使它打上了重复的入境错误!
您可使用表格和触发器具,以实施像顺序一样的矿石:
drop table if exists users_seq;
create table users_seq
(
next_val int unsigned not null default 0
)
engine=innodb;
drop table if exists users;
create table users
(
user_id int unsigned not null,
username varchar(32) unique not null
)
engine=innodb;
delimiter #
create trigger users_before_ins_trig before insert on users
for each row
begin
declare v_id int unsigned default 0;
select next_val + 1 into v_id from users_seq;
set new.user_id = v_id;
update users_seq set next_val = v_id;
end#
delimiter ;
insert into users_seq values (0);
insert into users (username) values ( alpha ),( beta );
Query OK, 2 rows affected, 1 warning (0.03 sec)
select * from users_seq;
+----------+
| next_val |
+----------+
| 2 |
+----------+
1 row in set (0.00 sec)
select * from users;
+---------+----------+
| user_id | username |
+---------+----------+
| 1 | alpha |
| 2 | beta |
+---------+----------+
2 rows in set (0.00 sec)
insert into users (username) values ( alpha );
ERROR 1062 (23000): Duplicate entry alpha for key username
select * from users_seq;
+----------+
| next_val |
+----------+
| 2 |
+----------+
1 row in set (0.00 sec)
select * from users;
+---------+----------+
| user_id | username |
+---------+----------+
| 1 | alpha |
| 2 | beta |
+---------+----------+
2 rows in set (0.00 sec)
insert into users (username) values ( gamma );
Query OK, 1 row affected, 1 warning (0.03 sec)
select * from users_seq;
+----------+
| next_val |
+----------+
| 3 |
+----------+
1 row in set (0.00 sec)
select * from users;
+---------+----------+
| user_id | username |
+---------+----------+
| 1 | alpha |
| 2 | beta |
| 3 | gamma |
+---------+----------+
3 rows in set (0.00 sec)
希望它有助于:
回答载于你的问题:简言之,这并不使它自动增加一栏。 相反,数字显示正确的价值分析,处理重复的关键错误。
仅仅把这个领域确定为是绝对的,而没有非洲联盟-联合国达尔富尔混合行动,你就可以控制这个领域的价值。
就在这种“丑闻”中。 与这种行为一样,因为它使我申请中的“UNI Request”一栏的任何使用不相称。
www.un.org/Depts/DGACM/index_spanish.htm 因此,我的解决办法是:,在添加和从独一无二钥匙上辞职之前,检查是否存在独特的钥匙(与选取钥匙)。
I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...
<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...
我把我的用心从使用QQL转向MySQL。 它与凯科特合作,现在不工作,因为我已经改变,使用MySQL。 这里的错误信息是:
We have a restaurant table that has lat-long data for each row. We need to write a query that performs a search to find all restaurants within the provided radius e.g. 1 mile, 5 miles etc. We have ...
Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...
Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...
What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...
My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...