question

SandeepRaj252 avatar image
SandeepRaj252 asked

Need to Fetch the data which are not present based on one particular ID

There is one master table which contains all the details of the customer. A view is been created on this master table to fetch the data from all other child tables which are connected to master table using foreign key constraints. There is one seller table which has the information about seller who sold to which customer, I want to show data of the master table for the seller who has not sold to a customer so that he can be assigned to the new customer. Note: one customer can have multiple seller assigned to him
databasejoinsunion
4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ThomasRushton avatar image ThomasRushton ♦♦ commented ·
By "not sold to a customer", do you mean "not sold to any customer", or "not previously sold to *this* customer"?
0 Likes 0 ·
ThomasRushton avatar image ThomasRushton ♦♦ commented ·
Also, some more concrete examples would help us to get a clearer picture of what you're up to / what you require. See, for example, https://spaghettidba.com/2015/04/24/how-to-post-a-t-sql-question-on-a-public-forum/
0 Likes 0 ·
SandeepRaj252 avatar image SandeepRaj252 commented ·
not sold to any customer
0 Likes 0 ·
SandeepRaj252 avatar image SandeepRaj252 commented ·
sold to some customers but need to fetch the customers data which he has not been sold
0 Likes 0 ·

1 Answer

·
ThomasRushton avatar image
ThomasRushton answered
Without access to your schema, it's difficult to know, but something along these lines? Tables * Seller - SellerID (key), company name, address, etc * Customer - CustomerID (key), name, shipping address, etc * Transactions - TransactionID, SellerID, CustomerID, Date, etc... Query: SELECT * FROM Seller WHERE SellerID NOT IN ( SELECT SellerID FROM Transactions ) Something like that?
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.