sql - Big Mysql Query (Join counts in the result and modify a string) -
I'm new to mysql so please forgive my knowledge level here, and hesitate to direct me in a better direction. Do not
My Table:
Server:
/ p>
| Server id (int) | Article ID (Int.) | Location ID (int) | | 1 | 46 | 55 | | 2 | 11 | 81 | 3 | 81 46 | | 4 | 55 | 11 | | 5 | 81 99 | | 5 | 11 | 52 | Article:
| Paragraph (int) | Name (varchar) | Type | | 46 | Domain | 0 | | 81 Root-server | 1 | | 55 | Making | 2 | | 11 | Root-server2 1 | Location:
| Location id (int) | Location (varchar) | | 46 | 1-5-15-2. | 81 1-5-14-2. | 55 | 2-25-1- 9. | 11 | 21-2-5-8. | 99 | 17-2-5-8. | 52 | 1-8-5-8 || Result:
| Place (integer) | Name (varchar) | Count | | 1 | Root-server | 1 | | 1 | Root-server2 2 | | 17 | Root-server | 1 | The first number of space in the location space table is the block (1-5-15-2 -> 1, 1-8-5-8 -> 1, 21-2-5-8 -> 21, 17-2-5-8 -> 17). Counting is the same number of all servers with the same name and first place block.
Do anyone think that this result is to be obtained in only one query?
Thanks for any of the answers!
check this
SELECT SUBSTRING_INDEX (location, '-' , 1) Enter the form of the lid as a place, such as Article.Name, Count (*) as the location on the Server.locationID connect to the server from the location. Location.locationID Article.ArticleID = Article by Article: Article.ArticleID;
Comments
Post a Comment