Leser: 2
|< 1 2 3 >| | 28 Einträge, 3 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
mysql> select * from a;
+------+------+
| a_id | name |
+------+------+
| 1 | foo |
| 2 | bar |
| 4 | baz |
+------+------+
3 rows in set (0.00 sec)
mysql> select * from b;
+------+--------------------+
| b_id | descr |
+------+--------------------+
| 2 | descr for bar |
| 3 | descr for whatever |
| 4 | descr for baz |
+------+--------------------+
3 rows in set (0.01 sec)
mysql> select * from a INNER JOIN b on a.a_id=b.b_id;
+------+------+------+---------------+
| a_id | name | b_id | descr |
+------+------+------+---------------+
| 2 | bar | 2 | descr for bar |
| 4 | baz | 4 | descr for baz |
+------+------+------+---------------+
2 rows in set (0.01 sec)
mysql> select * from a LEFT JOIN b on a.a_id=b.b_id;
+------+------+------+---------------+
| a_id | name | b_id | descr |
+------+------+------+---------------+
| 1 | foo | NULL | NULL |
| 2 | bar | 2 | descr for bar |
| 4 | baz | 4 | descr for baz |
+------+------+------+---------------+
3 rows in set (0.00 sec)
mysql> select * from a RIGHT JOIN b on a.a_id=b.b_id;
+------+------+------+--------------------+
| a_id | name | b_id | descr |
+------+------+------+--------------------+
| 2 | bar | 2 | descr for bar |
| NULL | NULL | 3 | descr for whatever |
| 4 | baz | 4 | descr for baz |
+------+------+------+--------------------+
3 rows in set (0.01 sec)
1
2
3
4
5
6
7
8
9
SELECT
id, count(id) as anzahl, sum(bewertung) as 'bew', sum(bewertung) / count(id) as durchschnitt
FROM
bewertung
GROUP BY
id
ORDER BY
durchschnitt desc
LIMIT 10
sum(bewertung) / count(id) as durchschnitt
|< 1 2 3 >| | 28 Einträge, 3 Seiten |