user6917062
user6917062

Reputation:

MySQL data type for a field with only two possible options

I'm trying to work out which data type to use for a field in my database that can only be one of two options: 'dual' or 'solo'.

I realise that this is essentially Boolean but I can't use tinyint(1) because the inputs are not numbers.

If anyone could give me an idea of what to use in this situation it would be greatly appreciated :)

Upvotes: 0

Views: 1140

Answers (1)

Barmar
Barmar

Reputation: 782584

You can use ENUM

colname ENUM('dual', 'solo')

Internally it will be stored as a TINYINT, but when storing and retrieving it will use the strings.

Or you could use TINYINT. The terms "dual" and "solo" refer to 2 and 1 participants, so you could have

participants TINYINT(1)

and store 1 for solo and 2 for dual.

Upvotes: 2

Related Questions