sql - Comparing value in a table vs count of rows in other table -
i have 2 tables (primary key - unit_id) , b (primary key - unit_id)
i have value (eg :4 ) in table , has unit_id.
i have 4 rows in table b same unit id
i have write sql query check whether value in table matches count (rows) in table b same unit_id
you can use inner join , see how many values table in table b :
select a.unit_id table1 inner join table2 b on a.unit_id = b.unit_id
im assumin need , because @stanislavl pointed out, cant have more 1 unique unit_id in each table.
Comments
Post a Comment