Hi all, I need your help.
I’ve this two queries in MySQL database with time of execution very good:
mysql> SELECT
COUNT(*) AS q,
application
FROM
`dotable__backup`
WHERE
application NOT IN ('home page')
GROUP BY
application
ORDER BY
q DESC;
+-------+---------------+
| q | application |
+-------+---------------+
| 22963 | Report one |
| 13957 | Report two |
|.......|...............|
|.......|...............|
|.......|...............|
+-------+---------------+
51 rows in set
Time: 0.187ms
SELECT
COUNT(*) AS q,
application
FROM
`dotable`
WHERE
application NOT IN ('home page')
GROUP BY
application
ORDER BY
q DESC;
+-------+---------------+
| q | application |
+-------+---------------+
| 23613 | Report one |
| 13790 | Report two |
|.......|...............|
|.......|...............|
|.......|...............|
+-------+---------------+
59 rows in set
Time: 0.171ms
Now I need this output with the sum of values on two tables:
+-------+---------------+
| q | application |
+-------+---------------+
| 46576 | Report one |
| 27747 | Report two |
|.......|...............|
|.......|...............|
|.......|...............|
+-------+---------------+
And tried this query join:
SELECT
COUNT(*) AS q,
u.application
FROM
`dotable__backup` U
JOIN `dotable` tmp ON U.application = tmp.application
WHERE
u.application NOT IN ('home page')
GROUP BY
u.application
ORDER BY
q DESC;
In this case the output is:
[Err] 2013 - Lost connection to MySQL server during query
Can you help me?
The field application
in all tables is key Normal BTREE and type CHAR lenght 100, not NULL and default empty string.
With EXPLAIN SELECT this is the output, it all seems ok:
mysql> EXPLAIN
SELECT
COUNT(*) AS q,
u.application
FROM
`dotable__backup` U
JOIN `dotable` tmp ON U.application = tmp.application
WHERE
u.application NOT IN ('home page')
GROUP BY
u.application
ORDER BY
q DESC;
+----+-------------+-------+-------+---------------+--------------+---------+-----------------------+--------+-----------------------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+-------+---------------+--------------+---------+-----------------------+--------+-----------------------------------------------------------+
| 1 | SIMPLE | U | index | application | application | 100 | NULL | 282144 | Using where; Using index; Using temporary; Using filesort |
| 1 | SIMPLE | tmp | ref | application | application | 100 | db.U.application | 4133 | Using index |
+----+-------------+-------+-------+---------------+--------------+---------+-----------------------+--------+-----------------------------------------------------------+
2 rows in set
Thank you in advance.
PS: congratulations for new graphic forum, beautiful work!