Hi, Your solution would work if the set of the values you'll get from one table is primary key.. If it is not a primary key, i.e. allowing duplicate values, then everytime there is an insertion to the table you will have to check to see if it is a new-added value or not.
Gurhan -----Original Message----- From: Andrew Hazen [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 17, 2002 1:58 PM To: 'Gurhan Ozen'; 'Simon Tienery'; [EMAIL PROTECTED] Subject: RE: LOOKUP That's what I thought too. A workaround occurs to me though, but I'm not sure if it would muck things up. At any point where you make a change to the table you want to reference as the "lookup" (as in Access), you could include another sql command to alter the table with the enum column to change the list of accepted values for the enum. Would this work Gurhan, or would the constant ALTER table commands mess things up? Andrew Hazen -----Original Message----- From: Gurhan Ozen [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 17, 2002 1:46 PM To: Andrew Hazen; 'Simon Tienery'; [EMAIL PROTECTED] Subject: RE: LOOKUP Ugh, I am being too goofy today.. Simon, the answer to the question is no, you can't do that in MySQL. You can, however, create a column with enum datatype and define set of valid values. In a case where you try to insert an invalid value to an enum field, it will insert an empty string for it. Sincerely, Gurhan -----Original Message----- From: Andrew Hazen [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 17, 2002 12:54 PM To: 'Gurhan Ozen'; 'Simon Tienery'; [EMAIL PROTECTED] Subject: RE: LOOKUP Gurhan, I think Simon was looking for a way to make the enum dynamic from another table. ?????? Andrew Hazen -----Original Message----- From: Gurhan Ozen [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 17, 2002 10:22 AM To: Simon Tienery; [EMAIL PROTECTED] Subject: RE: LOOKUP Hi .. You can define ENUM datatype for a column while creating the table and along with the possible values, and if you are using phpMyAdmin to admin MYSQL, it will only give you the possible values for that ENUM column. See: http://www.mysql.com/doc/C/o/Column_types.html http://www.phpmyadmin.net/ Gurhan -----Original Message----- From: Simon Tienery [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 17, 2002 3:50 AM To: [EMAIL PROTECTED] Subject: LOOKUP Dear Group, Could anyone help me please, I want to create an ENUM column in one table that lists the entries in another table. For example, the sales table to have a "staff" column that automatically gives a choice of the names of all staff listed in the staff table. I have been told that Access has a data type that does this called lookup, but I only want to use MySQL. I couldn't locate the answer in the manual and I'd appreciate it if someone can explain how this can be achieved / worked around. many thanks Simon T --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php