0

Basically just as the title says, in MySQL can I specify a specific range of values for a column so a choice can be selected when a record is added.

I am only starting to understand MySQL and I know that you can do this MS-Access. I'm not sure but do I have to put something special in the 'Length/Values' column when designing? If I can do it, where do I specify what values would be selectable?

If not, is there a more efficient work around then creating a new table and relating the specified values as a foreign key.

Cheers

homer5677
  • 585
  • 1
  • 6
  • 11
  • Use `INSERT` trigger for that http://stackoverflow.com/a/8559284/251311 But depending on data nature - another table and FK might be a cleaner solution – zerkms May 08 '14 at 01:00

1 Answers1

1

MS Access combines a few functionalities into a single program:

  • A database engine (MS Jet)
  • A programming environment with a programming language (VBA)
  • A table editor
  • A table data editor
  • A form editor
  • A report editor
  • A query editor
  • ... more

MySQL is a database engine only. So there is no natural "Select Box" to input data. This would need to come from your programming environment or form generator.

That said, there is support for such a data type: Use ENUM - e.g. CREATE TABLE test (saluation ENUM ('Mr.', 'Mrs.'));

Eugen Rieck
  • 64,175
  • 10
  • 70
  • 92
  • Perfect that is what I needed. Sorry if I wasn't that clear but this what I'm after. Cheers – homer5677 May 08 '14 at 01:09
  • Is there anyway that I can have this but be able to hold multiple values? – homer5677 May 09 '14 at 02:51
  • An ENUM can have many different elements, e.g. `ENUM ('A', 'B', 'C', 'D', 'E', 'F')` – Eugen Rieck May 09 '14 at 02:57
  • I'm not sure I understand it correctly. Within the cell that the ENUM selection occurs can I have it have multiple ENUM values? Eugen, if so is this how you do it? – homer5677 May 09 '14 at 03:03
  • Ah, I understand: You want to store a **list** in a field. This is almost never a good idea, use a join table, that has its own PK, the PK of the table as a FK and an ENUM field. To add a value, create a record in this table. – Eugen Rieck May 09 '14 at 03:10