使用這個問題在那裏與Get Last Row of Different id then display data that is greater than zero獲取最後一行或最小的數據,那麼在連接兩個表
我想加盟另一臺
這是我的表2
+----+--------+
| id | name |
+----+--------+
| 1 | Taylor |
| 2 | Zac |
| 3 | Scott |
| 4 | Emma |
+----+--------+
如果我使用此代碼...
SELECT DISTINCT t1.id, t1.amount, t2.name FROM table1 t1, table2 t2 WHERE t1.amount = (SELECT MIN(t1.amount) FROM table1 WHERE id= t1.id) AND t1.[t1.amount]>0 AND t1.[id]=t2.[id];
...然後這些結果顯示...
+----+--------+-------+
| id | amount | name |
+----+--------+-------+
| 2 | 100 | Zac |
+----+--------+-------+
僅1數據顯示
我想是在表
+----+--------+-------+
| id | amount | name |
+----+--------+-------+
| 2 | 100 | Zac |
| 4 | 200 | Emma |
+----+--------+-------+
您是否試過將't1。[t1.amount]'改爲't1.amount'? – toonice