I am confused about a mysql Query problem. I am so confused when I wait online, the Chinese name of table t1 field stored in table t2 t1t2 is manifested in the desire to write an SQL statement, which can be used to find out & nbsp; id & nbsp; in table t1 (a mysql Query problem, online and so on.
The brain is confused.
I have two tables, table t1 stores data, and table t2 stores the Chinese names of table t1 fields.
T1
Table t2
Now I want to write an SQL statement to find the sum of the values of each field in id in (1, 2, 3, 4, 5) in table t1, replace the field name with the corresponding Chinese field name in table t2,
The result is similar
Array (
"Attach to attack" => 6,
"Brute Force effect" => 7,
....
)
How should I write a statement? I thought it was not difficult. Why didn't I suddenly think my neck was full of cramps?
Is there a problem with table design? Is there a better way to query mysql tables:
------ Solution --------------------
It cannot be seen that 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 );
In this way, the sum of the five col fields can be queried. However, the updates behind you are not regular and it seems that you can only write them to death.
------ Solution --------------------
It seems that you have a problem with table design. This is an m2m relationship. Generally, three tables are designed.
I understand you as an additional weapon property in the game:
Table a: Weapons
Id name
1
Table B: attribute table
Id desc
1. attach n to attack
2. restore the lifecycle of n.
Table c: weapon property ing table
Id a_id B _id n
1 1 1 24
2 1 2 30
The data in Table c shows that weapon A attach 24 to attack and the lifecycle is 30.
For personal accounts, see! Don't like it, don't spray it!
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