-3

Long story short,

I'm trying to create a table, where you can enter a company name. However you cannot enter a company name which contains a string value of a previous entered company name. Is this possible to do with a check constraint? For example:

My company "CrazyJello" is inserted. Now the following companies that are being entered to MySQL cannot have the string "Crazy" in them.

CREATE table company(
name VARCHAR (100)
CHECK (name != ?????)
7
  • Can they have the string Jello in them Commented Oct 24, 2022 at 12:39
  • And how are you going to identify, programattically, why Crazy cannot be used again but Jello can Commented Oct 24, 2022 at 12:46
  • @RiggsFolly I should've read it through. No you should not be able to write Crazy nor jello. I.E the whole string should be of limits to the next insert Commented Oct 24, 2022 at 12:52
  • Umm, so i cannot have JelloHeaven because you use CrazyJello and I cannot have ShoppingGoneCrazy either because you already used Crazy Commented Oct 24, 2022 at 13:02
  • 1
    One of the real difficult bits is going to be getting the code to identify these words within a string. I cannot think of a way to do it, so I hope you have already planned how to decide that troy would not make roy invalid. Again just an example Commented Oct 24, 2022 at 13:22

1 Answer 1

0

No, in sql there is the unique index, but it compares the whole content of the field https://www.mysqltutorial.org/mysql-unique/

Sign up to request clarification or add additional context in comments.

1 Comment

Really only a comment

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.