How to remove one of the elements in the MySQL field collection

Source: Internet
Author: User

In a one-to-many scenario, we use a comma concatenation to store, avoid storing multiple, or sub-table, then there is a storage on the need to modify if necessary, it brings difficulty, such as the Rule record table as follows

If the 2nd rule is deleted, then all of this table has 2 records to be cleared out, at this time the problem is troublesome, you need to determine whether to use Find_in_set and then take out the loop, remove 2, and then loop write, if a different way of thinking with a string to solve, then it is convenient for the specific program as follows

This idea is very peculiar, the use of string substitution, all the string before and after the comma, and then, 2, for, and then filter the comma, so that you can replace the things you need to substitute, and start I want to directly replace, I found that if 2 just at the beginning or the end, it is easy to have problems, then after thinking , it is better to transform this field, the field before and after the comma, so that the match can be replaced, the efficiency is more efficient than to detect and recycle and then cycle the update efficiency is much higher ah, but things are handed to the database to do, maybe the database pressure to answer some. There must be some lost ah, haha ha! Reminds me of the team leader to leave three days, the team leader is very cool, colleagues to work the kind of uncomfortable, ha ha, a flower open, there is a flower defeat, the inevitable truth of the development of things ah, ah haha ha!

How to remove one of the elements in the MySQL field collection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.