database table design is very flexible, is it so easy to make SQL statements?

Source: Internet
Author: User

Due to the needs of the project, we configure some infrequently variable constants through the data fields and update the data through the database fields when the system is initialized. The following is a description of the example.

I have a watch like this.

, you will find that Meterkindid and Measureid are code, only the data dictionary configured by the data can parse out the values we want, the following is the data dictionary table structure

, so the design is very flexible, FieldID for the column name, ID is the value of the table above, value is the parsed value, that is, the code corresponding to the name, and then send a dictionary of the data graph

MK001 and MK002 corresponding data dictionary of water meters and meters, MS001 and MS002 corresponding data dictionary measurement units are tons or degrees, then how we investigate this effect, such as:

, carefully comparing the above chart, you will find that the type and units are joined, before the long-thinking SQL statements are not written out, and later found a very convenient way, SQL statements are as follows

With this SQL, you can implement the requirements. However, if you encounter a problem, use stored procedures to report a. Pricetypeid not exist, depressed. Let's fix it.

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: 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.