How to match SQL and Extracted data

Use Case :
Fetch orders from Website stores 1,2,3 (At a time only store 1 or 2 or 3 )
There are 2 types of customers : A and B having various order numbers.
B types of customers are in each stores.
Check in SQL data that if tracking available for particular order or no ?
If yes then update those on website.

Issue :
For customer type A in store number 1 has order 12345,
Store 2 has same order 12345 in Customer B ,
So what my code is doing , Updating store 2’s detail in Store 1’s Order.

Current Code : Code is matching order numbers only.

What I need to update here? If you can please send me sample flow or explain me.
Thank You in advanced

@PALKUMARI_PATEL As you mentioned at a time only one store being processed(Fetch orders from Website stores 1,2,3 (At a time only store 1 or 2 or 3 )) If that is the case if Store 2 has some order then it should update in store 2, how it is updating in store1’s order

I have stored procedure created and parameters for each store’s account to check tracking for that particular store.
Ex: Store 1 executing, It found order number type of A customer , (B customers are common for all stores so in stored procedure we have same parameter that I am using for each stores)

Now, Bot checked order number with customer type A on store 1, If not it try to check for type B which is common for all and it picked up Store 2’s order details as customer B and updated in Store 1.

Can you provide me a query to get SQL’s column number 4’s (xyz) data . I am using assign activity but somehow mistaking in write the equation.