Multiple choice question
Is there a performance difference between the following two queries applied on the table below?
Query 1:
SELECT a.id, SUM(a.flags) AS flags FROM tbl a INNER JOIN (SELECT DISTINCT id FROM tbl WHERE (7&flags) ) AS b USING (id) GROUP BY id DESC;
Query 2:
SELECT a.id, SUM(a.flags) AS flags FROM tbl a Join tbl b USING (id) WHERE (7&b.flags) GROUP BY a.id DESC;
Given the following table:
| id |
flag |
text |
| 1 |
1 |
some text 1 |
| 1 |
2 |
some text 2 |
| 2 |
4 |
some text 3 |
| 3 |
1 |
|
| 3 |
8 |
|