I have two tables in a MySQL database
urltracker with columns id and urlclicked and urlreferrer with columns id, url_id and urlreferrer
the urltracker is really just a lookup table with the url_id column in the urlreferrer table being the link between the tables.
Example DDL:
CREATE TABLE urltracker (
id SERIAL PRIMARY KEY,
urlclicked VARCHAR(200) NOT NULL
);
CREATE TABLE urlreferrer (
id SERIAL PRIMARY KEY,
url_id BIGINT UNSIGNED NOT NULL,
urlreferrer VARCHAR(200) NOT NULL
FOREIGN KEY(url_id) REFERENCES urltracker(id)
);
What i wany to do is join the two tables in such a way that i can get the url that was clicked by looking up the urlclicked table and the total number of referrers from the urlreferrer table for this particular url.
I have messed about with this for 2 hours and i'm not getting anywhere, im no database expert can anyone please explain how to achieve this.
Thanks in advance