选择并通过联接更新以提供不同的记录

时间:2018-12-14 06:26:48

标签: sql sql-server database join inner-join

我有两个关系表

  • 表分配
  • 桌票

分配表中有一个字段是状态。因此,我正在从状态为complete并返回6909 records

的表分配中获取记录

比起我,我使用状态为complete的内部联接返回记录,同时也返回了6909记录。

但是当我使用join并以相同的条件更新表时,更新6625的记录不是6909。查询是否有任何问题?请指导

查询:

首先:返回6909条记录

SELECT * FROM [ITSC].[dbo].[assignment] where assignment_status = 'Completed' 

第二:返回6909条记录

SELECT tickets.ticket_submitted_by , tickets.ticket_type , tickets.ticket_open_date , tickets.ticket_priority , tickets.ticket_description , assignment.staff_name,assignment.assigned_time_start,assignment.assigned_time_end,assignment.assignment_status
from tickets 
inner join 
assignment 
on tickets.ticket_id = assignment.ticket_id
where assignment.assignment_status = 'Completed'

第三次:更新6625条记录,而不是6909条

 update tickets set tickets.ticket_close_date = '2015-04-29' 
,tickets.ticket_close_time = '2015-04-29 09:25:40.670' from tickets
 inner join assignment
 on tickets.ticket_id = assignment.ticket_id
 where assignment.assignment_status = 'Completed'

1 个答案:

答案 0 :(得分:1)

您可以尝试查询

***************************
APPLICATION FAILED TO START
***************************

Description:

Field restTemplate in cloud.test.server.rest.clients.TenantRestClient required a bean of type 'org.springframework.web.client.RestTemplate' that could not be found.


Action:

Consider defining a bean of type 'org.springframework.web.client.RestTemplate' in your configuration.