English 中文(简体)
A. 如何选择更新指挥
原标题:how to select command with in update command

i have three table

table t1;
Sid sValue
1   abc
2   bcd

table t2
Sid  Pid  Mid
1    a    9
2    a    10
3    b    9

table t3
Mid  MValue
9    ZZZZ
10   yyyy

i want to update table t1 and set t1.sVal="" where t2.Pid= a and t3.MValue= zzzz

how can i do this pls help me thanks in advance

i have tried it like

update t1 set sVal="" where Sid=(select Sid from t2 where Pid= a  and Mid=(select Mid from t3 where MVale= ZZZZ ))

but it doesnt work and thorw error like

An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Add a name or single space as the alias name. 
最佳回答

The problem is that you are using double quotes instead of single quotes in your set statement.

定点数

不包括Val=”

但是,如果你想作更清洁的更新说明,则该守则应当这样做。

update t1 定点数
from t1
inner join t2 on t1.sid=t2.sid
inner join t3 on t2.Mid=t3.Mid
where t2.Pid= a  and t3.MVale= ZZZZ 
问题回答

为此:

update t1 SET t1.sVal =   
INNER JOIN t2
ON t1.sid = t2.sid
INNER JOIN t3
ON t2.mid = t3.mid
WHERE t2.Pid= a  and t3.MValue= zzzz 




相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

SQL server: Can NT accounts be mapped to SQL server accounts

In our database we have an SQL server account that has the correct roles to access some of the databases. We are now switching to windows authentication and I was wondering if we can create a NT user ...

SQL Server 2000, ADO 2.8, VB6

How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8

热门标签