To fetch all the orders issued against the salesman who may work for a customer with the ID 5002, you can use the following SQL query:
```sql
SELECT O.*
FROM Orders O
WHERE O.SalesmanID IN (
SELECT S.SalesmanID
FROM Salesmen S
WHERE S.CustomerID = 5002
);
```
In this query:
- `Orders` should be replaced with the actual name of your orders table.
- `Salesmen` should be replaced with the actual name of your salesmen table.
- `SalesmanID` should be replaced with the actual name of the column that links orders to salesmen.
- `CustomerID` should be replaced with the actual name of the column that stores customer IDs in the salesmen table.
This query uses a subquery to find the SalesmanIDs of salesmen who work for the customer with ID 5002 in the "Salesmen" table. Then, it selects all the orders with SalesmanIDs found in the subquery result, effectively fetching all the orders issued against those salesmen.
#sql
Watch video To fetch all the orders issued against the salesman who may work for a customer with the ID 5002 online without registration, duration hours minute second in high quality. This video was added by user Parag Dhawan 07 October 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 40 once and liked it people.