I’m moving tables from an .accdb file to MySQL. In Access 2010, I could use “Row Source” query to get acceptable values from another table. (Like an ENUM type in MySQL which fills its set dynamically using a query.)
For example, for the LendedTo column in the LendedBooks table, I use the query
SELECT [Members].[Name] + ' ' + [Members].[Surname]
FROM Members
ORDER BY [Members].[Name] + ' ' + [Members].[Surname];`
How can I do this in MySQL?
In MySql you can use a foreign key constraint (i.e., relationship) to link two tables together. So the
LendedTocolumn inLendedBookswould be a relationship to the primary key field (say,ID) ofMembers. When you create the relationship you can then enforce that the only allowed values are those that satisfy the relationship.If you have more complicated field requirements, then you can look into the concept of check constraints. Check constraints are not directly supported in MySql but can be emulated with the help of triggers.