首页 > 解决方案 > 从 MySQL 中选择不同的选项

问题描述

我有从 MySQL 表中选择选项的表单。因为我想要唯一的选项,所以我添加了 SELECT DISTINCT... 但我有如下值: R15 和 R15C 现在我想将这两个组合到只有 15 显示在选择选项中?

当前代码:

$result = $conn->query("SELECT DISTINCT diameter FROM tires WHERE cat = 'cars' ORDER BY diameter ASC"); while($rows = $result->fetch_assoc()){ $diameter = $rows['diameter']; ?>
<option value="<?php echo $diameter; ?>"><?php echo $diameter; ?></option>

标签: phpdistinctdistinct-values

解决方案


我刚刚添加了它以使其正常工作

AND premer NOT LIKE '%C%'

推荐阅读