A MySQL query about the problem, will be able to paste immediately

Source: Internet
Author: User
A MySQL query problem, online, etc. will be able to paste immediately
I'm so confused, I can't get around this bend.

I have two tables, the T1 table stores the data, and the T2 table stores the Chinese names of T1 field fields.

T1



T2 table



Now you want to write an SQL statement, you can find out the T1 table ID in (1,2,3,4,5) of the records of each field value and replace the field name to the T2 table corresponding to the text field name,

The results are similar to
Array
"Add when attacking" = 6,
"Crit Effect" = 7,
....
)

How should the statement be written? It was supposed to be easy, but I couldn't think of it.

Is there a problem with the table design? There's no better way MySQL table Design Enquiry

Share to:


------Solution--------------------
I don't see how the result array corresponds to the data in the table.
------Solution--------------------
Select SUM (col1), sum (col2), sum (col3), sum (COL4), sum (COL5) from T1 where ID in (1,2,3,4,5);

This makes it possible to query the sum of five col fields, but there are no rules behind your update, and it seems that you can only write dead.
------Solution--------------------
It feels like you have a problem with your watch design. This is a relationship between the two, the general design of 3 tables.
I'll think of you as an additional property of the weapon in the game:
Table A: Weapons table
ID Name
1 A
Table B: Property sheet
ID DESC
1 attack Attach N
2 Health Value Recovery n

Table C: Weapon attribute mapping table
ID a_id b_id N
1 1 1 24
2 1 2 30

The data in Table C shows the weapon a attack plus 24, health recovery 30

Personal humble opinion! Don't like to spray!
  • 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.