vanvoquan Posted June 19, 2008 Share Posted June 19, 2008 I try to eliminate the duplicate values with Select Distinct but is doesn't work. Can anybody tell me why is not working. Any suggestion will be greatly appricitate. Here is the [<td><?php $datas=$_GET['keywords']; $result=mysql_db_query($dbname,"SELECT products_id FROM products_description WHERE products_name LIKE'%$datas%'"); while($category1 = mysql_fetch_array($result)) { $result2=mysql_db_query($dbname,"SELECT categories_id FROM products_to_categories WHERE products_id='". $category1['products_id'] ."'"); while($category2 = mysql_fetch_array($result2)) { $result3=mysql_db_query($dbname,"SELECT parent_id FROM categories WHERE categories_id='". $category2['categories_id'] ."'"); while($category3 = mysql_fetch_array($result3)) { $result5=mysql_db_query($dbname,"SELECT parent_id FROM categories WHERE categories_id='". $category3['parent_id'] ."'"); while($category4 = mysql_fetch_array($result5)) { $result6=mysql_db_query($dbname,"SELECT parent_id FROM categories WHERE categories_id='". $category4['parent_id'] ."'"); while($category5 = mysql_fetch_array($result6)) { $result7=mysql_db_query($dbname,"SELECT DISTINCT categories_description.categories_name, categories.categories_id, categories.parent_id FROM categories_description, categories WHERE categories_description.categories_id = categories.categories_id AND categories.categories_id ='". $category5['parent_id'] ."'"); while($row = mysql_fetch_array($result7)) { echo $row['categories_name']; echo "<br>"; } } } } } } ?></td>/code] Quote Link to comment Share on other sites More sharing options...
vanvoquan Posted June 19, 2008 Author Share Posted June 19, 2008 Can anyone please help me with this. Millions thanks Vanvoquan Quote Link to comment Share on other sites More sharing options...
fenway Posted June 19, 2008 Share Posted June 19, 2008 DISTINCT is not a function -- it will only removes duplicates across the entire column list, not just the first field. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.