【发布时间】:2012-01-21 11:56:57
【问题描述】:
更新:谢谢大家,现在使用这个查询可以 100% 工作:
SELECT e.entry_id
FROM exp_channel_titles AS e
INNER JOIN exp_matrix_data AS m ON m.entry_id = e.entry_id
WHERE e.channel_id = 2
GROUP BY e.entry_id
ORDER BY MIN(m.col_id_2) ASC
这是我的代码。
来自 .home_laagste_rentes 的代码
{exp:channel:entries dynamic="no" fixed_order="0{embed:entry_ids}" disable="member_data|pagination|categories"}
<tr class="{switch="odd|even"}">
<td><a href="#" title="{title}">{title}</a></td>
<td>{dk:lowest col="rente" decimals="2" dec_point=","}%</td>
<td>{count}</td>
</tr>
{/exp:channel:entries}
页面代码:
<table id="rowspan" cellspacing="0" class="tablesorter">
<thead>
<tr>
<th>Krediet aanbieder</th>
<th>Rente</th>
<th>Beoordeling</th>
</tr>
</thead>
<tbody>
{embed="embeds/.home_laagste_rentes"
entry_ids="{exp:query sql="
SELECT DISTINCT (e.entry_id)
FROM exp_channel_titles AS e
INNER JOIN exp_matrix_data AS m ON m.entry_id = e.entry_id
WHERE e.channel_id = 2
ORDER BY m.col_id_2 ASC
"}|{entry_id}{/exp:query}"}
</tbody>
col_id_2 设置为十进制(10,4)
entry_id 设置为 int
这是过滤重复的,但它没有给出正确的顺序。看起来过滤重复项是随机完成的...有关输出,请参见此链接: http://postimage.org/image/9vzahuuez/
【问题讨论】:
-
那不是创建链接表的查询..请张贴孔查询
-
嗨 Rauschen,刚刚更新了完整代码..
-
@TVoskuilen 你能把表
exp_channel_titles和exp_matrix_data的SCHEMA贴出来吗? -
使用这个查询它工作正常:SELECT e.entry_id FROM exp_channel_titles AS e INNER JOIN exp_matrix_data AS m ON m.entry_id = e.entry_id WHERE e.channel_id = 2 GROUP BY e.entry_id ORDER BY MIN(m.col_id_2) ASC
标签: mysql sql-order-by distinct expressionengine