多个表的SQL查询

时间:2011-01-09 11:01:02

标签: sql

  

可能重复:
  SQL AND operator not working properly

我有以下两个表

LandParcels表

Blockid ParcelNo storPri
 ======= ======== ======= 
52000105   3      State 
52000105   4      Private 
52000105   5      State
52000401   12     State
52001002   23     State

行动表

Blockid ParcelNo ActionTaken
 ======= ======== ===========
52000105   3      Received 
52000105   3      Send to Computer 
52000105   4      Received 
52000105   5      Received
52000401   12     Received  
52001002   23     Received 

我想过滤所选的blockid(例如:52000105)并且不记录“发送到计算机”

累计。到两个表

例如。我想过滤来自landparcels的记录,其中blockid 52000105并没有发送到计算机(仅“收到”)

我想要这样的结果(Selected Block是52000105)

Blockid ParcelNo ActionTaken
 ======= ======== ===========
52000105   4      Received 
52000105   5      Received

1 个答案:

答案 0 :(得分:0)

  

从LandParcels内部联接中选择*   对LandParcels.Blockid =的操作   Actions.Blockid其中Actions.Blockid   = 52000105和ActionTaken ='已接收'