mysql - Return all rows from sub-query SQL? -


I have now written query query to get rows through the first query:

  SELECT * fROM commenttoarticle to AkidCommentToArticle by an OU AkidCommentToArticle = (ones commenttoarticle b CommentToArticlePID) DESC orders LIMIT 3  

when I try to execute this query, I get:

  # 1242 - Subquery lays more than 1  

How to solve this problem? Therefore, I need to get all the rows from the sub-query.

If I want to return a line - I need to use GROUP BY , but this is not a solution

> Modified query:

  commenttoarticle select a commenttoarticle b a.idCommentToArticle where a.CommentToArticlePID (from a.idCommentToArticle by idCommentToArticle) DESC 3   

Dump table comment comment :

  if not create 'comment comment' (`idCommentToArticle` int (11) does not autoconnect, CommentToArticleTime` Integer (11) No NULL , `CommentToArticleIdArticle` integer (11) zero,` CommentToArticleComment` text not NULL, `CommentToArticleIdUser` integer (11) No NULL,` CommentToArticlePID` integer (11) No NULL, primary key (`IdCommentToArticle`), unique key 'idCommentToArticle_UNIQUE `(` IdCommentToArticle`)) engine = MySQL default charge = utf8 AUTO_INCREMENT = 59; - - Damp Dantichentikl - 'comments include Letartikl` ( `idCommentToArticle`,' Tippnituartikl Time ',' Tippnituartiklinstrykl 'Tippnituartikl comment', 'Tippnituartiklaidusr' Tippniotroiklpiaidi ') value (29, 0, 11,' продажам? \ NИнтересует не мега-звезда, а именно предметный, руками умеющий продавать сам и помогающий выстраивать это бизнесам. ', 459, 0), (30, 0, 11,' 2 ', 459, 0), (31, 0, 11 , '3', 45 9, 0), (36, 0, 11, '3.1', 45 9, 31), (37, 1413822798, 11, 'also facing the problem Yes, 459, 29, '(38, 0, 11,' I do not have an internet connection here. Thank you to Siamant Sinha, please check it out tomorrow. ', 45 9, 29) , (39, 0, 11, 'Choose the maximum ID and you will have the last line', 45 9, 29, (32, 0, 11, '4', 45 9, 0), (44, 1414354324, 11, 'How to Do', 456, 29), (45, 1414354469, 11, 'SFFF', 456, 29), (46, 1414354708, 11, 'DDDD', 456, 29), (47, 1414357761, 11, 'SFFS', 456, 0), (57, 1414370833, 39, 'KKPPPPPP', 456, 0), (49, 1414358233, 11, 'VSF \ n SFSF', 456, 0), (50, 141435 9 59, 11, 'How to do', 456, 0), (51, 1414359660, 11, Sfffdiadi, 456, 0), (52, 1414361057), 11, Sdifsf ', 456, 0), (53, 1414364023, 11, Disfdijfisfmisi', 456, 0), (54, 1414364031, 11 'Sdifdisk Jefanskef', 456, 52), (55, 1414364034, 11 'sdfdskjfnskf', 456, 52), (56, +1414364044, 11, 'fndsdfnsofosfi', 456, 52), (58, +1414370841, 39, 'dfgdfgdgdgdgdgdfgdgdfg', 456, 0);  

What do I need:

Here is an example on sqlfiddle: unlimited COMMENTTOARTICLEPID for each first question, if present For example, rows with IDCOMMENTTOARTICLE: 58, 57, 56, 52

Need to get.

I'm thinking that your subkey returns to more than 1 line so replace your "=" with "IN". Like this ...

  Choose from commenttoarticle in an a.idCommentToArticle (from commenttoarticle b SelectToArticlePID) by ordering a.idCommentToArticle DESC LIMIT in order 3  

Comments