【发布时间】:2021-02-14 04:25:45
【问题描述】:
我有从 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>
【问题讨论】:
-
你要添加一些样本数据,你的问题不够清楚,我们不知道你想结合什么,它应该基于什么
-
您将尝试用类似这样的方式模糊不同的查询...stackoverflow.com/questions/12165400/fuzzy-distinct-values
-
好的。目前我在 mysql... R13,R14,R13,R15,R15C,R16,R14,R15,.... 与 Select Distinct 我得到:R13,R14,R15,R15C,... 但我想得到: R13,R14,R15,R16...谢谢
标签: php distinct distinct-values