- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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)
Advertisements