Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8564587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:14:02+00:00 2026-06-11T17:14:02+00:00

I have this query SELECT COUNT( CASE WHEN restricted LIKE ‘%us%’ THEN 2 ELSE

  • 0

I have this query

SELECT 
    COUNT(
            CASE 
                WHEN restricted LIKE '%us%' THEN 2 
                ELSE 1 
            END) AS totalcount 
FROM 
    reviews 
WHERE 
    restricted LIKE '%us%'

This counts the total number of values like “us” appearing in a column (restricted). This column is filled by values from a muultiselect checkbox in this “unusual” manner:

*us*ca*uk* etc.

And this works. No problem.

Now, I need to count where this value (us) is NOT appearing.
I tried to do this, a “classic”.

SELECT 
    COUNT(
            CASE 
                WHEN restricted NOT LIKE '%us%' THEN 2 
                ELSE 1 
            END
    ) AS totalcount 
FROM 
    reviews 
WHERE 
    restricted NOT LIKE '%us%'

I have declared the statemenent NOT LIKE but now… the problem… it count also rows where ‘restricted’ column is NOT FILLED (some listings don’t use this column). And the count is wrong.

Can anyone help, please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:14:03+00:00Added an answer on June 11, 2026 at 5:14 pm

    empty value or null value on ‘restricted’ column will pass “restricted NOT LIKE ‘%us%’
    ” statement. try change to:

    SELECT 
        COUNT(
                CASE 
                    WHEN restricted NOT LIKE '%us%' THEN 2 
                    ELSE 1 
                END
        ) AS totalcount 
    FROM 
        reviews 
    WHERE 
        restricted NOT LIKE '%us%' 
        AND restricted != '' 
        AND restricted IS NOT NULL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mysql query like this: $topicreplycount = mysql_query('SELECT COUNT(DISTINCT post_msg_id) FROM phpbb_attachments
I have a query like this: SELECT COUNT(*) AS amount FROM daily_individual_tracking WHERE sales
I have an sql query like this: SELECT IF( (SELECT COUNT(*) FROM `test_table2` WHERE
I have a very simply query like this: SELECT users.id, COUNT(others.id) as c FROM
I have the following query: Select Count(Distinct Case When Play.Uuid Like ('i~%') Then Tap.Player_Id
I have this query: SELECT COUNT(articles.id) AS count FROM articles, xml_documents, streams WHERE articles.xml_document_id
i have this simple query : SELECT YEAR(P.DateCreated) ,MONTH(P.DateCreated) ,COUNT(*) AS cnt FROM tbl1,
I have following query working : SELECT COUNT(id), AgeRange FROM ( select id, case
i have following query working.. select count(id) , case when age < 0 then
so suppose I have this query SELECT COUNT(*) FROM (SELECT * FROM k JOIN

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.