Redian新闻
>
urgent help! insert value into table
avatar
urgent help! insert value into table# Database - 数据库
c*t
1
What is the sql command for inserting values into a table?
The table has just one column called id, which is double type.
The id is unique. If I insert bunch of id's into the table,
some of might be duplicate. What to do in that case?
Thanks
avatar
n*m
2
when you create the table, you can specify col as UNIQUE.
But I am not very sure whether it will work on double data

【在 c*****t 的大作中提到】
: What is the sql command for inserting values into a table?
: The table has just one column called id, which is double type.
: The id is unique. If I insert bunch of id's into the table,
: some of might be duplicate. What to do in that case?
: Thanks

avatar
xt
3
What do you mean? Table with only 1 column? you can do
CREATE TABLE T ( value FLOAT NOT NULL, PRIMARY KEY( value ) )
avatar
s*a
4
use either primary key or unique to make sure there is no dupicate values.

【在 c*****t 的大作中提到】
: What is the sql command for inserting values into a table?
: The table has just one column called id, which is double type.
: The id is unique. If I insert bunch of id's into the table,
: some of might be duplicate. What to do in that case?
: Thanks

avatar
c*t
5
That's not what I meant. I meant that I have a existing SQL table
called Queue. It has a single column id. Given this table, I now
have a bunch of ids to put into the table. Yet, these ids may be
duplicated. The question is how to avoid the duplicate and at
the same time be as efficient as possible.
Thanks

【在 s*a 的大作中提到】
: use either primary key or unique to make sure there is no dupicate values.
avatar
f*g
6

Hope this query can work for the case:
INSERT INTO Queue (ID) SELECT @input_ID WHERE NOT EXISTS(SELECT * FROM Queue WHERE ID = @input_ID)

【在 c*****t 的大作中提到】
: That's not what I meant. I meant that I have a existing SQL table
: called Queue. It has a single column id. Given this table, I now
: have a bunch of ids to put into the table. Yet, these ids may be
: duplicated. The question is how to avoid the duplicate and at
: the same time be as efficient as possible.
: Thanks

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。