---
title: "How to search in same-type columns given a set of unsorted values?"  
description: "How to search in same-type columns given a set of unsorted values?"  
author: "Anonymous User"  
published: 2013-04-03  
updated: 2013-04-03  
canonical: https://www.mindstick.com/forum/703/how-to-search-in-same-type-columns-given-a-set-of-unsorted-values  
category: "mssql server"  
tags: ["mssql server"]  
reading_time: 2 minutes  

---

# How to search in same-type columns given a set of unsorted values?

Hi Everyone!\
I have a [system](https://www.mindstick.com/articles/23411/the-most-effective-method-to-find-the-perfect-small-business-phone-system-for-your-business) which backlogs [products](https://www.mindstick.com/news/2358/apple-will-use-us-made-semiconductors-in-its-products-to-lessen-its-dependency-on-asia) users receive within a box. The whole system is based on these kits we create with products inside.\
So I got a [Customers](https://www.mindstick.com/articles/13008/how-does-a-customer-portal-enhance-the-experience-of-customers) and Products which lists everything I have. And I have a Boxes table which has ProductID1, ProductID2, ProductID3 and ProductID4 [fields](https://www.mindstick.com/forum/159126/sql-query-for-all-tables-and-fields-in-an-oracle-db) \
and [CustomerID](https://www.mindstick.com/forum/156740/how-to-select-the-last-row-of-a-particular-customerid-in-sql-using-the-command) field to point which [customer](https://www.mindstick.com/articles/325839/how-to-improve-your-business-level-of-customer-service) received which box.\
All I want to do is, given a set of products not in the same order (Ex.: ID4, ID2, ID3, ID1) I need to know all customers that hadn't received any products \
of this given set.\
Is my [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) bad designed? What would be the best way to do this or how to make the [SELECT query](https://www.mindstick.com/articles/1858/sqlite-select-query)\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!

## Replies

### Reply by AVADHESH PATEL

Hi Tanuj!\
You can do like this\
where id4 not in (productid1, productid2, productid3, productid4) or id2 not in (productid1, productid2, productid3, productid4) or id3 not in (productid1, productid2, productid3, productid4) or id1 not in (productid1, productid2, productid3, productid4)\
You should have a table called something like BoxesrProducts that would have a BoxesId and a ProductId. That way, boxes can have different sizes -- even \
beyond 4 products -- if that is desirable.


---

Original Source: https://www.mindstick.com/forum/703/how-to-search-in-same-type-columns-given-a-set-of-unsorted-values

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
