Solved

Count entries in enum field

Posted on 2007-04-03
2
445 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
Creating and Managing Databases with phpMyAdmin in cPanel.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

920 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

15 Experts available now in Live!

Get 1:1 Help Now