-2

我是 sql 查询的新手。

我正在处理与数据库的事务。

我想写一个 sql 查询,它只插入那些从 101 开始的数字。

sql = "insert into tablex where values 101123";
sql = "insert into tablex where values 10100";  
sql = "insert into tablex where values 101125";  

所有插入都应该使用仅以 101 开头的值。
数字 101123、10100、101123 来自带有某些程序的文本文件。

我只想在表格中插入那些以 101 开头的数字。

4

1 回答 1

1

您可以通过在查询中使用WHERE子句来限制插入的记录。

insert into yourtable (col1)
select yourColumn
from yourtable
where yourColumn >= 101

根据您的评论,也许您想要这样的东西:

insert into yourtable (col1)
select yourColumn
from yourtable
where yourColumn LIKE '101%'
于 2012-10-01T15:52:58.767 回答