shornesr Posted April 18, 2008 Share Posted April 18, 2008 MySQL version - 4.1.20 I have three fields in the table rows... FULL, AM and PM If the FULL field has an entry I want to make it so AM cannot be filled and PM cannot be filled. However, if AM is filled I want PM to be able to be filled as well and vica versa Quote Link to comment Share on other sites More sharing options...
fenway Posted April 18, 2008 Share Posted April 18, 2008 You can't do that with an index... maybe with a trigger. Quote Link to comment Share on other sites More sharing options...
shornesr Posted April 18, 2008 Author Share Posted April 18, 2008 Thanks for the quick response... I am sorry if my questions seem so basic. I really new at this but really love it! What do you mean by "trigger" ? Quote Link to comment Share on other sites More sharing options...
shornesr Posted April 18, 2008 Author Share Posted April 18, 2008 Actually, I just found a basic tutorial on triggers... thanks! I can see how to update and instert, etc... How would you prevent and entry from being made? Quote Link to comment Share on other sites More sharing options...
fenway Posted April 18, 2008 Share Posted April 18, 2008 Actually, I just found a basic tutorial on triggers... thanks! I can see how to update and instert, etc... How would you prevent and entry from being made? I suppose you could use a BEFORE INSERT trigger and check; to be honest, I'm not really using 5.0, so I haven't played much with them. Quote Link to comment Share on other sites More sharing options...
gluck Posted April 19, 2008 Share Posted April 19, 2008 Dude I don't think you can do it with the mysql version you have. This needs to involve a programming language for that. Now with triggers you will looking at a before insert/update stmt. If you are firing an insert I believe you can just insert FULL and not AM/PM You know what just ensure the integrity via the programming language through the queries you fire. Quote Link to comment Share on other sites More sharing options...
dsmythe Posted April 19, 2008 Share Posted April 19, 2008 This would be much easier to do with your application code rather than MySQL. Just do a quick SELECT first and see if there is data in FULL. If there is, stop your script from allowing someone to add data to AM or PM, etc. Build the logic into your application and use MySQL to store your information. -Dan- Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.