|
declare @tb_product table (p_code int, p_status int)
insert @tb_product
select 111, 7
union all select 222, 8
union all select 333, 9
declare @tb_usemode table (u_code int, u_status int)
insert @tb_usemode
select 111, 1
union all select 111, 1
union all select 222, 3
union all select 222, 2
union all select 333, 0
select p_code, u_code, p_status, u_status = min (u_status)
from @tb_product a inner join @tb_usemode b on a.p_code = b.u_code--where where is changed to on
where u_status> 0--Exclude the landlord from showing that this record is 0
group by p_code, u_code, p_status
(The number of rows affected is 3)
(The number of rows affected is 5)
p_code u_code p_status u_status
----------- ----------- ----------- -----------
111 111 7 1
222 222 8 2
(The number of rows affected is 2) |
|