I have two database tables:
Table 1:
+---------+-------+-------------+
| Page | Title | Description |
+---------+-------+-------------+
| Apple | ..... | ........... |
| Orange | ..... | ........... |
| Pear | ..... | ........... |
| Grapes | ..... | ........... |
+---------+-------+-------------+
Table 2:
+----------+-------------+
| Link | Page |
+----------+-------------+
| Website1 | Apple |
| Website2 | Orange |
| Website3 | Apple |
| Website4 | Orange |
| Website5 | Apple |
| Website6 | Pear |
| Website7 | Apple |
| Website8 | Grapes |
| Website9 | Grapes |
+----------+-------------+
I want to know / return how many pages from table 1 are listed in table 2 and how many times they link. (I DO NOT want to know how many times EVERY page in table 1 is listed in table 2).
So, in this example: 1 page links 1 time (Pear), 2 pages link 2 times (Grapes and Orange) & 1 page links 4 times.
Which SQL statement would I use for this?
source
share