asp.net - Why it don't fetch DISTINCT category from database -


i have table id , category columns. want fetch distinct category database couldn't expected.it gives me output categories table.

i have block of code:

var selectuniquecategory="select distinct(category),id images"; var selecteduniquecat=db.query(selectuniquecategory,category,id);     @foreach(var row in selecteduniquecat) {                 <p><a href="#" data-target="#row_thumbnails">@row.category </a>                    <a href="/editcategory?id=@row.id">&nbsp;<span class="glyphicon glyphicon-pencil"></span></a>                  </p> } 

in each loop want perform 2 tasks:

1: distinct category table

2: fetch id column , pass each id related category id=@row.id

if remove id query, like:

var selectuniquecategory="select distinct(category) images"; var selecteduniquecat=db.query(selectuniquecategory,category); 

it works fine distinct category table want fetch both category distinct , id primary in table.

 hi everyone,     have found solution problem felt should share here also.      earlier question said want category , associated id simultaneously. following code did work me.  var selectquery="select * images";                       var selecteddata=db.query(selectquery,category,imagepath);                        var selectuniquecategory="select distinct category images order category";                       var selecteduniquecat=db.query(selectuniquecategory,category); 

<a href="/editcategory?id=@{foreach( var sendid in selecteddata )                                             {                                                 if(row.category==sendid.category)                                                 {                                                     @sendid.id                                                 }                                             }}" >&nbsp<span class="glyphicon glyphicon-pencil"></span></a></p>                }
worked me.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -