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 8837135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:39:00+00:00 2026-06-14T09:39:00+00:00

Hello all, I have a quick problem with mysql query. I’m trying to do

  • 0

Hello all, I have a quick problem with mysql query.

I’m trying to do a selection and I’m not sure it can be done – or if I’m doing it right.

I have a table with a field called ListeningMethod, which contains values from a comma separated array values, inserted from html check boxes.
There are 5 possible entries and the field can have all, or none of the checkbox values in it.

The sample data would be similar to this:

NOLISTEN,RADIO,INTERNET,SATELLITE,MOBILE

What I’d like to do is sort the data, but do it by counts. So, if there are 10 appearances of “RADIO”, 5 of “MOBILE” and 3 of “SATELLITE” spaced over 10 records, then searching through 100 records, it should be able to show and sort those mentioned results, with the “order by” set to the most common listeningmethod at the top.

I tried giving it a go, but didn’t go too well.

Any thoughts?
Thanks.

SELECT 
ListeningMethod, 
ListeningMethod REGEXP ("NOLISTEN") as ViewNOLISTEN,
ListeningMethod REGEXP ("RADIO") as ViewRADIO,
ListeningMethod REGEXP ("INTERNET") as ViewINTERNET,
ListeningMethod REGEXP ("SATELLITE") as ViewSATELLITE,
ListeningMethod REGEXP ("MOBILE") as ViewMOBILE
FROM VAT

I tried adding more, such as “COUNT(ViewRadio) CountRadio”, but it says that column doesn’t exist, so I’m a little lost.

Example Insert statement:

INSERT INTO `VAT` (`ListeningMethod`) VALUES ('NOLISTEN,RADIO,INTERNET,MOBILE');
INSERT INTO `VAT` (`ListeningMethod`) VALUES ('RADIO');
INSERT INTO `VAT` (`ListeningMethod`) VALUES ('RADIO');
INSERT INTO `VAT` (`ListeningMethod`) VALUES ('RADIO');
INSERT INTO `VAT` (`ListeningMethod`) VALUES ('RADIO');
INSERT INTO `VAT` (`ListeningMethod`) VALUES ('RADIO');
INSERT INTO `VAT` (`ListeningMethod`) VALUES ('INTERNET');
INSERT INTO `VAT` (`ListeningMethod`) VALUES ('RADIO'); 
INSERT INTO `VAT` (`ListeningMethod`) VALUES ('RADIO');
INSERT INTO `VAT` (`ListeningMethod`) VALUES ('NOLISTEN');
INSERT INTO `VAT` (`ListeningMethod`) VALUES ('INTERNET');
INSERT INTO `VAT` (`ListeningMethod`) VALUES ('RADIO');
INSERT INTO `VAT` (`ListeningMethod`) VALUES ('INTERNET');
INSERT INTO `VAT` (`ListeningMethod`) VALUES ('RADIO');
INSERT INTO `VAT` (`ListeningMethod`) VALUES ('RADIO');
INSERT INTO `VAT` (`ListeningMethod`) VALUES ('RADIO');
INSERT INTO `VAT` (`ListeningMethod`) VALUES ('MOBILE');
> 
  • 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-14T09:39:01+00:00Added an answer on June 14, 2026 at 9:39 am

    You could use separated table as suggested by Barmar in the comment, other(un-)wise you can create a temporary table like that using union as given below: (If you have no problem with union and sub-query):

    SELECT * FROM
    (
        SELECT "NOLISTEN" AS "ListeningMethod", COUNT(ListeningMethod) as "AMOUNT" FROM VAT WHERE ListeningMethod LIKE "%NOLISTEN%"
        UNION
        SELECT "Radio" AS "ListeningMethod", COUNT(ListeningMethod) as "AMOUNT" FROM VAT WHERE ListeningMethod LIKE "%RADIO%"
        UNION
        SELECT "INTERNET" AS "ListeningMethod", COUNT(ListeningMethod) as "AMOUNT" FROM VAT WHERE ListeningMethod LIKE "%INTERNET%"
        UNION
        SELECT "SATELLITE" AS "ListeningMethod", COUNT(ListeningMethod) as "AMOUNT" FROM VAT WHERE ListeningMethod LIKE "%SATELLITE%"
        UNION
        SELECT "MOBILE" AS "ListeningMethod", COUNT(ListeningMethod) as "AMOUNT" FROM VAT WHERE ListeningMethod LIKE "%MOBILE%"
    ) AS VAT2 ORDER BY AMOUNT DESC;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello all this seems to be my problem I have a table in mysql
Hello all I have this problem that I can't seem to fix. I've been
Problem Hello all! I have this code which takes my jpg image loops through
Hello all i have a button i am trying to let users share a
Hello all I have a simple Spring application which will not end as there
Hello all i have a simple problem i have a alertDialog and i want
Hello all I have a problem with understanding the bitsort program in Bentley's classic
Hello All Does anyone know if you can have a deferred GridSplitter resize in
Hello all I have a Delete link that I'm trying to create with the
Hello all I have a question I hope you guys can help me with.

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.