I have 6 tables with IDs of customers. It is posible, in one query, to get the customers ids that coincide in all tables? In my example, the customers ids that results are 8 and 9 (it must be taken into account, that in practice, any of the tables may have values or not)
Many thanks Best regards
DECLARE @TCustomerAge TABLE(
CustomerID INT not null );
DECLARE @TCustomerLocalization TABLE(
CustomerID INT not null );
DECLARE @TCustomerGroup TABLE(
CustomerID INT not null );
DECLARE @TCustomerStore TABLE(
CustomerID INT not null );
DECLARE @TCustomerSales TABLE(
CustomerID INT not null );
DECLARE @TCustomerPayment TABLE(
CustomerID INT not null );
--@TCustomerAge empty
insert into @TCustomerLocalization values (8), (9), (11)
insert into @TCustomerGroup values (8), (9), (10), (11)
insert into @TCustomerStore values (8), (9), (11)
--@@TCustomerSales empty
insert into @TCustomerPayment values (2), (3), (5), (8), (9), (10)
-- Result -> 8, 9