Darkness Soul Posted December 1, 2006 Share Posted December 1, 2006 Yo,I'm with a little problem.. when I do a search into my corps table, it return many lines (like, if you search for "ab" it will return 3875), and I have an IF into my select:[code]SELECT tbE.id , IF ( palavrachave_vip LIKE "%ab%" , "V" , IF ( tbE.cliente = "S" , "S" , "N" ) ) AS vipFROM[/code]I need to take these result and count, how much "V" and "S" I have, because they use an different css to display of each other.. and I need to count how much i'll display per time to don't broke my layout.. like it:Page one can display:8 result "N", or 5 result "V", or 6 result "S" or, 3 result "V" and 3 result "S"..Do you understood? I don't know if I take the idea clear to you..Well, is it. Thank you..D.Soul Link to comment https://forums.phpfreaks.com/topic/29102-how-to-count-results/ Share on other sites More sharing options...
artacus Posted December 2, 2006 Share Posted December 2, 2006 Are you looking for a summary? (no individual records) I'm not sure if V/S are mutually exclusive, but try:[code]SELECT SUM(IF(palavrachave_vip LIKE "%ab%,1,0)) AS num_v, SUM(IF(tbE.cliente = "S",1,0)) AS num_s, COUNT(tbE.id) AS num_recordsFROM...GROUP BY tbE.id[/code] Link to comment https://forums.phpfreaks.com/topic/29102-how-to-count-results/#findComment-134117 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.