我有一张表SEND,只有一列Aname:7 M3 Q4 y5 {6 J' I4 W
Aname ------GREAME PETER另一个RECEIVE有两列表:- Z; T( ]7 c% r9 I. x
Aname Permission-----------------------------------------------GREAME (copied from table SEND) 'my own value will be inserted here, specified in insert query'PETER (copied from table SEND) 'my own value will be inserted here, specified in insert query'现在,如上所示,我只想把它放在表里RECEIVE的Aname列插入新表,SEND在第二列中,我将插入一个新值。, s1 P' g, B) m+ E
另外,我希望不能RECEIVE重复值插入表中:3 q- D2 R* W7 o6 k) n1 w4 ?
我要这个: ?( ]. O5 e! \0 D/ o6 @Aname Permission---------------------GREAME PLAYERGREAME PLAYER --- COULD NOT BE INSERTEDGREAME SALESMAN --- COULD BE INSERTED使用此查询:8 W5 c% W8 r/ `5 H {# m) K7 \
insert into receive(Aname,Permission) select Aname ,'Select' from SEND where not exists (select * from RECEIVE where Aname = 'GREAME' and Permission = 'select')该查询从SEND同时在表中获取名称GREAME&PETER并将其插入RECEIVE但我希望我只选择手表,GREAME,而不选择PETER。 2 f4 E( v# p: w3 y/ v我该怎么办? + A! {7 C8 L' p* K它从表SEND接收所有行,插入表RECEIVE但我希望只插入一行。所以我想查询一下,但它给出了语法错误: " ~/ \$ w [( g( p6 z# v) cinsert into RECEIVE(Aname ,Permission) select Aname ,'select' from SEND WHERE Aname = 'GREAME' -------------this line gives error where not exists (select * from RECEIVE where aname = 'GREAME' and Permission = 'select + c5 C" t7 S% b. c- w$ `8 X# o 解决方案: