Solved

Count entries in enum field

Posted on 2007-04-03
2
444 Views
Last Modified: 2008-01-09
I have entered survey data into a MySQL database. I have built reports to process much of the data, but I'm stuck on the best way to handle some enum fields.

I have four fields called Type1, Type2, Type3, Type4.
Type1 has the values "Full-time" & "Part-time"
Type 2 has "Solo" & "Group"
and so on.

I want to do a count query to return a report to tell me how many responded Full-time, Part-Time, Solo, Group, and so on for each option of each enum field.

I know I can do a separate query for each option of each field, but there has to be a more efficient way.
0
Comment
Question by:RKFcomputers
2 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 500 total points
ID: 18843876
You can do it in one way, but if it is faster, I dont know. Its done like:
select
  count(if(Type1='Full-time', 1, null)) as FullTime,
  count(if(Type1='Part-time', 1, null)) as PartTime,
 ...
FROM Table
0
 

Author Comment

by:RKFcomputers
ID: 18844686
Thanks ... that's doing the trick.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now