I'm beginning to study SQL queries and attempting to understand some more difficult ones. I have these 2 tables:
User
ID_user
Name
Tracking
ID_Track
Old_Value
New_Value
Date_Entered
ID_user
The data entry interface looks like this:
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
I'm trying to figure out how to join User and Tracking tables in order to know when the word “Checked” was added and who added it.
CodePudding user response:
know when the word Checked was added and who added it
You can filter the tracking
table for the keyword, and then bring the user name with a join
on the user
table:
select t.*, u.name
from tracking t
inner join user u on u.id_user = t.id_user
where t.new_value = 'Checked'
You can add more conditions in the where
clause if you need more filtering criteria.