m******o 发帖数: 61 | 1 我用的是mysql,有一个table:
columnA, columnB
1,a
2,b
我要create一个batch insert,里面有可能已经有1,a 和2,b. 这种情况我不想再
insert进去了。我试着加了个unique key 在columnA+columnB,可是这样的话,一旦遇
到duplicate的数据,mysql就停止insert了。 请问怎样让mysql继续insert那些不
duplicate的数据? |
|
c*******e 发帖数: 8624 | 2 ☆─────────────────────────────────────☆
myyaoyao (瑶瑶妈) 于 (Wed Mar 11 15:19:46 2009) 提到:
我用的是mysql,有一个table:
columnA, columnB
1,a
2,b
我要create一个batch insert,里面有可能已经有1,a 和2,b. 这种情况我不想再
insert进去了。我试着加了个unique key 在columnA+columnB,可是这样的话,一旦遇
到duplicate的数据,mysql就停止insert了。 请问怎样让mysql继续insert那些不
duplicate的数据?
☆─────────────────────────────────────☆
neil222966 (Wei) 于 (Wed Mar 11 18:52:23 2009) 提到:
没用过mysql,不知道以下几种方法是否对你有用。
Option1:
cursor
loop
If not exists (Select ... From ...)
Insert into |
|
c*********t 发帖数: 9 | 3 have a prepared statement:
update table set columnA = 'OK' where columnB in ?;
for example,
update table set columnA = 'OK' where columnB in (1,2,3);
===========================================================
In java code, how to pass (1,2,3) to the prepared statement?
thanks! |
|
n*******A 发帖数: 273 | 4 Purchased on Columnbs Day
MSRP $23,521 (2012 2.5X Automatic transmission , Alloy Wheel package with
some other small options)
Purchased price: $19,920(including destination)
DMV/TTL fee: ~$365
+ Tax
OTD: $21,940
0 down 0% for 36 months. |
|
z***p 发帖数: 22 | 5 终于遇上明白人了,呵呵,多谢多谢!
还有一点点不明白的是:您说要在columnC加上收入,指的是在columnC的哪一栏呢?
21c,21f,还是别的什么地方?如果是21f,应该怎么describe?
另外,columnB上是不是全部填0?
谢谢! |
|
z*****8 发帖数: 3043 | 6
弱问scheduleA line 1 的wages,columnA填的是1040上的,
那columnB呢?填一样的吗? |
|
o*****i 发帖数: 1783 | 7 我以前坐灰狗从DAYTON去纽约 (灰狗以前是是每到一个车站,全体乘客下车),所以
我路经columnbs 灰狗站.我没觉得有什么不安全的。一般灰狗站都在downtown。
这里上车前排队很有意思,在人少的地方随便放个包就算排队了,人都不知道跑那里去
了,要是在国内车站,包早被拿走了吧。。。
打车要花不少钱吧,两个多小时的路呢。 |
|
n*l 发帖数: 44 | 8 I generated TableA and TableB in "subqueries" of the SQL statement, say
Table A: Table B:
columnA columnB columnC |
|
n*l 发帖数: 44 | 9 I got the following error message says missing a keyword. The AB in your
code, is it the new table name?
SQL> select A.columna as newa, A.columnb as newb, b.columnc as news
2 into AB
3 from A, B
4 ;
into AB
*
ERROR at line 2:
ORA-00905: missing keyword
So basically this is a cartesian join? |
|
n********6 发帖数: 1511 | 10 Some examples.
TABLEA.COLUMNA
'20070101'
@DATA LIKE '2007%'
@DATA = SUBSTRING('20070101', 1, 4)
TABLEB.COLUMNB
'12132007'
LIKE '____2007' *4 underscores
LIKE '%2007'
More
TABLEC.COLUMNC
'03/16/2007'
... |
|
g***l 发帖数: 18555 | 11 isnull(columnA, columnB) |
|
i****a 发帖数: 36252 | 12 如果我從 CTE 做 UPDATE, for example:
;with CTE as
(select columnA
, row_number() over (order by columnB) as row_num
from TableA
)
Update C
SET columnA = 'testing'
from CTE C
where row_num < 10
Question is, will the query pull all records from TableA, or only 10 rows
with row_num < 10? |
|
i****a 发帖数: 36252 | 13 Do you see any problem with set rowcount?
BOL says:
Important:
Using SET ROWCOUNT will not affect DELETE, INSERT, and UPDATE statements in
the next release of SQL Server. Avoid using SET ROWCOUNT with DELETE, INSERT
, and UPDATE statements in new development work, and plan to modify
applications that currently use it. We recommend that DELETE, INSERT, and
UPDATE statements that currently are using SET ROWCOUNT be rewritten to use
TOP.
As I understand it should be ok because the select statemen... 阅读全帖 |
|
i****a 发帖数: 36252 | 14 I thought Rank and Row_Number does the same thing except the numbering. didn
't know they would lock records differently.
I think any order by method would result in the same behavior? only
difference may affect it is the indexing on the column.
Let's say columnB in my example is indexed, does SQL server still need to
retrieve all records for sorting in the CTE example?
specific rows. RANK may works much better if applicable. |
|
s********e 发帖数: 893 | 15
在oracle里,where 也可以明确leftjoin,right join
where t1.columnA = t2.columnB(+) |
|
|
c*********r 发帖数: 2733 | 17 String str =update table set columnA = 'OK' where columnB in (?,?,?);
//conn is a connection
PreparedStatement ps = conn.prepareStatement(str);
ps.setInt(1,1);
ps.setInt(1,2);
ps.setInt(1,3); |
|
P****D 发帖数: 11146 | 18 不是,这个题目里这个错误是SQL引起的。
macro variable name结尾放一个点,表示这个variable的名字结束了,以免跟后面的
部分混淆。这个你知道吧?
SQL里面,“点”的语法作用是 数据集名 点 变量名,比如 dataA.columnB。
所以这个题目里面需要两个点,一个点表示&data这个macro variable的名字结束了,
第二个才负责连接数据集的名字和变量的名字。
两个macro variable套到一起用&&var&i.。 |
|
T*********n 发帖数: 45 | 19 如果我有这样一个data,
columnA columnB
A B
A C
A D
B C
B D
C D
E F
E G
F G
......
这个data意思是: A=B, A=C, B=C
我现在要的是把equation关系简化以下到:
A B
A C
A D
E F
E G。
这个在SAS里面怎么做? |
|