Syntax error Which MySQL Datatype should be used for storing BloodType?

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)
Updated on: 2019-12-26T06:35:52+05:30

992 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements