Jump to content

How to count results?


Darkness Soul

Recommended Posts

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 vip
FROM
[/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
Share on other sites

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_records
FROM...
GROUP BY tbE.id
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.