mysql查出n條數(shù)據(jù),其中有四條數(shù)據(jù)兩兩重復(fù),還有其他的也是這樣,如何去重?

2023-06-18 14:11

1個回答
SELECT * FROM(
select * from customer where user=(
SELECT source_user from customer WHERE user='admin') UNION ALL select * from customer where user=(
select source_user from customer where user=(
SELECT source_user from customer WHERE user='admin')) union ALL select * from customer where user=(
select source_user from customer where user=(
select source_user from customer where user=(
SELECT source_user from customer WHERE user='admin'))) UNION ALL select * from customer where source_user=(/*我的上線的上線的user*/
select user from customer where user=(
select source_user from customer where user=(
SELECT source_user from customer WHERE user='admin'))) union all select * from customer where source_user=(/*我的上線的上線的上線user*/
select user from customer where user=(
select source_user from customer where user=(
select source_user from customer where user=(
SELECT source_user from customer WHERE user='admin'))))) as alias group by user;
相關(guān)問答
mysql如何查詢最新的5條數(shù)據(jù)
2個回答2022-12-15 11:08
進(jìn)入mysql管理頁面,點擊進(jìn)行執(zhí)行SQL語句頁面,輸入以下內(nèi)容:SELECT * from 你要查的表名 where 自增長的主鍵/日期 ORDER BY createtime DESC LIMIT...
全文
mysql數(shù)據(jù)庫如何查詢一條記錄?
1個回答2022-12-15 18:25
不知道你用的什么語言 這是sql語句 select * from use u where u.name=? and u.pass = ? 如果數(shù)據(jù)庫里有這條記錄就會返回1或更多沒有就返回0 然后在判斷...
全文
mysql:只用一條sql語句,如何查出一個表里,不同條件對應(yīng)的數(shù)據(jù)條數(shù)
1個回答2022-11-01 11:58
看一下這個SQL select sum( if((sex?=?1?and?age?=?2),1,0) ), sum( if((sex?=?1?and?age?=?5),1,0) ), sum( if...
全文
MySQL查詢第n季度沒有,n-1季度有的數(shù)據(jù)?
1個回答2023-05-19 04:15
表的結(jié)構(gòu)是一列重倉股股票
如何查看mysql某個表所有數(shù)據(jù)
3個回答2022-12-15 15:37
select * from user 這樣就可以了
mysql中怎么查看數(shù)據(jù)表內(nèi)容
1個回答2022-12-02 00:01
mysql -uroot -p 輸入root密碼進(jìn)去,比如你要查看mysql這個數(shù)據(jù)庫下user表的內(nèi)容 select * from mysql.user;
數(shù)據(jù)庫怎么查看表中有多少條數(shù)據(jù)
1個回答2023-01-19 03:03
其實我感覺你這個邏輯沒問題,代碼有點問題,我是這么認(rèn)為的,代碼應(yīng)該是這樣 $idzhi = rand(0,表中數(shù)據(jù)條數(shù)); $data = $data['id']; // 我不明白你這里是什么意思 $...
全文
如何查看mysql數(shù)據(jù)庫的用戶
1個回答2022-12-12 21:08
進(jìn)入MySQL終端use mysql;select User from user;就可以看到數(shù)據(jù)庫的用戶了。
mysql怎樣查詢一個表中所有數(shù)據(jù)
1個回答2023-02-28 23:35
輸出所有的字段及不使用謂詞如distinct,limit等、不分組匯總、不附加任何篩選條件和實施任何連接即可檢索出該表的所有數(shù)據(jù)。例如下列語句: select * from t1; * 號表示輸出...
全文
熱門問答