Bjaeg Bjaeg - 7 months ago 43
MySQL Question


I have a selector were I wish users to only see distinct 'items' from a table. Below I have code to loop through the results. If I change the query to SELECT * it works perfectly fine.

<select name="sample">
<option value="trail">Trail</option>
$set = $mysqli->query("SELECT DISTINCT set FROM trail ORDER BY category");
if ($set->num_rows != 0){
while($set_1 = $set->fetch_assoc()) {
$set_category = $set_1['category'];
$set_set = $set_1['set'];
<OPTION VALUE="<?php echo $set_set; ?>"><?php echo $set_category.' :: '.$set_set ?></OPTION>

Is DESTINCT depreciated? I can't figure out why it wouldn't work.

I have come here after checking other peoples questions regarding this topic. I Tried adding two columns and that displayed nothing as well.


set is a reserve word and so needs escaping like below. Moreover, refrain yourself from using any reserve word (or) key word as your table column name.

SELECT DISTINCT `set` FROM trail ORDER BY category