所有行我願做一個具體的查詢MySQL的:從選擇不同
select distinct name
from tablename
刪除重複。但是這隻給了我名字。從「選擇表不同的名字:」我想所有的列有一個WHERE條件返回:
select *
from tablename
where value= 1
我嘗試這樣做:
select *
from tablename
where value = 1 and exists (select distinct name
from tablename)
不幸的是它返回相同的數據:
select *
from tablename
where value = 1
這意味着我的查詢中存在一個基本缺陷。
有人可以幫我解決我的問題。先謝謝你。
添加一些示例表數據和預期結果。請格式化文本。 (不是圖片。) – jarlh
你有沒有嘗試過使用'group by'?是否需要聚合? –