- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MySQL ENUM column match for quoted values
Let us first create a table with ENUM type column −
mysql> create table DemoTable( isMarried ENUM('1','0') ); Query OK, 0 rows affected (0.46 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('0'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable values('1'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('1'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('0'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('0'); Query OK, 1 row affected (1.00 sec) mysql> insert into DemoTable values('1'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable values('0'); Query OK, 1 row affected (0.09 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+ | isMarried | +-----------+ | 0 | | 1 | | 1 | | 0 | | 0 | | 1 | | 0 | +-----------+ 7 rows in set (0.00 sec)
Following is the query wherein we are counting the quoted value i.e. records with ‘0’ insertion −
mysql> select count(*) from DemoTable where isMarried='0';
This will produce the following output −
+----------+ | count(*) | +----------+ | 4 | +----------+ 1 row in set (0.06 sec)
- Related Articles
- Set ENUM in MySQL for column values
- Set custom messages for enum values in MySQL
- Match column values on the basis of the other two column values in MySQL
- How Are MySQL ENUM values sorted?
- MySQL query to match any of the two strings from column values
- MySQL update column to NULL for blank values
- How can we match the values having backslashes, like ‘ab’, from MySQL column?
- Adding new enum column to an existing MySQL table?
- Should I use MySQL enum or tinyint for fields having values 1 and 0?
- Using MySQL IN() for some column values with underscore
- How do I select data from one table only where column values from that table match the column values of another table in MySQL?
- Do MySQL Can Enum type values contain spaces in it?
- MySQL Quoted table/field names vs unquoted names?
- How can I get enum possible values in a MySQL database?
- Adding characters in values for an existing int column in MySQL?

Advertisements