Problem selecting unique records...

# Thread: Problem selecting unique records...

1. Senior Member
Join Date
Dec 1969
Posts
1,100

## Problem selecting unique records...

Hi,<BR><BR>I have this problem in selecting unique records...<BR><BR>I need to select 4 unique records from a category which has more than one subcategory.<BR><BR>The problem occurs when I have the same record in different subcategories...<BR><BR>I cannot use "select distinct" or "group by" (because some of the records are more than in one subcategory from the same category they - from "select distinct" or "group by" perspective - are not unique).<BR><BR>The only way, as far as I see, is to work on records ID...to select the 4 records (I want 4 but there will be more of them because the same record may be in two or more subcategories) and compare between them...if I find some identical then...<BR><BR>How can I do this practically?<BR><BR>Any idea?<BR><BR>This is my select:<BR>----------<BR>sql= "SELECT products.productid, products.Nr, products.Author, products.Title, products.Subtitle, products.Sonder, products.Price, products.Old_price, products.FilePath, products.FileName, products.featured, links.product_id, links.subcatcode_id, subcat.catcode FROM subcat INNER JOIN (products INNER JOIN links ON products.productid = links.product_id) ON subcat.subcatcode = links.subcatcode_id WHERE products.New_books=True and not_shown=0 and (((InStr(1,&#039;" & str & "&#039;,(&#039;,&#039; & [productid] & &#039;,&#039;)))&#060;&#062;0)) and subcat.catcode=" & catcode <BR>---------<BR><BR>Here are those 4 (supposely) records I want: (((InStr(1,&#039;" & str & "&#039;,(&#039;,&#039; & [productid] & &#039;,&#039;)))&#060;&#062;0)) (which are randomly selected in another select).<BR><BR>I hope I was clear enough :)...<BR><BR>Thanks,<BR>Mircea

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## Clear as mud to me

Maybe you should show an *EXAMPLE* of the data you have and the results you want???<BR><BR>What really looks ugly is it *appears* that you are using a comma-delimited list in there??? You str appears to be a comma-delimited value, yes? WHY?<BR><BR>

3. Senior Member
Join Date
Dec 1969
Posts
1,100

## RE: Clear as mud to me

4. Senior Member
Join Date
Dec 1969
Posts
96,118