1
目前我有這個疑問:顯示一行僅適用於具有相同的order_id列在MySQL
SELECT refnumbers.order_id FROM orders INNER JOIN refnumbers ON (refnumbers.order_id = orders.ID)
WHERE refnumbers.refno LIKE '%MAGT-%'
這回24行,從refnumbers。我希望它通過(?)進行分組,所以如果有4行具有相同的order_id,則它只返回一行。
例如,它顯示了現在這個樣子:
OrderID: 2
OrderID: 2
OrderID: 2
OrderID: 3
OrderID: 3
我想它返回此:
OrderID: 2
OrderID: 3
如果您想分組,只需追加'GROUP BY refnumbers.order_id'。 – 2011-12-27 17:22:38