我开始学习SQL查询,并试图理解一些更困难的。我有这两个表:
用户
ID_user
Name
跟踪ID_Track
Old_Value
New_Value
Date_Entered
ID_user
数据输入接口如下所示:
User Column Date Old Value New Value
David (assistant) Status 02/2022 Pending Processing
David (assistant) address 02/2022 Miami New York City
David (assistant) Type 02/2022 House Apartment
David(assistant) Size 02/2022 Small Big
Peter(QA) Size 06/2022 - Medium
Peter(QA) Status 06/2022 - Checked
我正试图弄清楚如何连接用户和跟踪表,以便知道何时添加了单词"Checked"以及谁添加了它。
知道何时添加了Checked这个词以及是谁添加的
您可以在tracking
表中过滤关键字,然后在user
表中添加带有join
的用户名:
select t.*, u.name
from tracking t
inner join user u on u.id_user = t.id_user
where t.new_value = 'Checked'
如果需要更多的过滤条件,可以在where
子句中添加更多的条件。