vostro Posted July 15, 2011 Report Share Posted July 15, 2011 Labvakar, nevaru pareizi izvilkt no datu bāzes, ir tabula <PAGES> tur ir <page_id> un ir tabula <COMMENTS> un tur ir <comment_id> <page_id>! <page_id> norāda pie kura materiāla ir komentārs. Lieta tāda gribas, lai pie materiāla izvadās cik ir komentāru skaits. Piemērs lasīt tālāk komentāru (5) Kā vajag pareizi darīt šajā situācijā? Quote Link to comment Share on other sites More sharing options...
briedis Posted July 15, 2011 Report Share Posted July 15, 2011 (edited) SELECT p.*, COUNT(c.comment_id) FROM pages p LEFT OUTER JOIN comments c ON c.page_id = p.id GROUP BY c.comment_id Viens no variantiem, lai gan nav tas efektīvākais. Edited July 15, 2011 by briedis Quote Link to comment Share on other sites More sharing options...
php newbie Posted July 15, 2011 Report Share Posted July 15, 2011 tur laikam domāts count nevis sum Quote Link to comment Share on other sites More sharing options...
briedis Posted July 15, 2011 Report Share Posted July 15, 2011 tur laikam domāts count nevis sum Taisnība gan! Quote Link to comment Share on other sites More sharing options...
vostro Posted July 16, 2011 Author Report Share Posted July 16, 2011 (edited) Paldies! Bet kaut ko īsti nestrādā!! Edited July 16, 2011 by vostro Quote Link to comment Share on other sites More sharing options...
Kemito Posted July 16, 2011 Report Share Posted July 16, 2011 NU ja pareizi visu sastada, tad strada, cerams, ka tu vienkarsi neiemeti kaut kur koda sadu rindu un viss, jo tada gadijuma tiesam nestradas. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.