SELECTt.*,count(tbl_myr_share_comment.shareId)ascountFROM`tbl_myr_share``t`LEFTJOINtbl_myr_share_commentONtbl_myr_share_comment.shareId=t.shareIdWHEREt.userId=1ORDERBYt.shareIdDESCLIMIT10;明明數(shù)據(jù)庫有4條數(shù)據(jù),但是查詢的結(jié)果出來是一條數(shù)據(jù)。SELECTt.*,count(tbl_myr_share_comment.shareId)ascountFROM`tbl_myr_share``t`LEFTJOINtbl_myr_share_commentONtbl_myr_share_comment.shareId=t.shareIdWHEREt.userId=1GROUPBYt.shareIdORDERBYt.shareIdDESCLIMIT10但是我后面加一個groupby則得到了正確的數(shù)據(jù)。請問為什么有count的情況下加group才能得到正確的數(shù)據(jù)呢?
SQL語句大神請進。為什么只得到了一條數(shù)據(jù)?加個group by 才得到多條數(shù)據(jù)?
縹緲止盈
2019-03-29 22:11:19