
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Which MySQL Datatype should be used for storing BloodType?
To store BloodType, use varchar(3) or ENUM. Let us first create a table −
mysql> create table DemoTable1855 ( BloodType varchar(3) ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1855 values('A+'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1855 values('A-'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1855 values('B+'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1855 values('B-'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1855 values('AB+'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1855;
This will produce the following output −
+-----------+ | BloodType | +-----------+ | A+ | | A- | | B+ | | B- | | AB+ | +-----------+ 5 rows in set (0.00 sec)
- Related Articles
- MySQL isn’t inserting binary data properly? Which datatype should be used?
- For timestamp, which datatype is used in MySQL?
- Which datatype should I use for flag in MySQL?
- Which MySQL datatype to used to store an IP address?
- Which equals operator (== vs ===) should be used in JavaScript?
- Which datatype is should I use to set a column for 5-star rating?
- Which equals operator (== vs ===) should be used in JavaScript comparisons
- What HTML5 tag should be used for filtering search results.
- What should be used to implement MySQL LIKE statement in MongoDB?
- Among id, name, xpath and css, which locator should be used?
- Best data type for storing large strings in MySQL?
- Which Measurement Unit should be used in CSS to set letter spacing
- MySQL BIT_LENGTH() function is used for which purpose?
- Storing money amounts in MySQL?
- How should strace be used on Linux?

Advertisements