I am creating a url reduction / redirection service, and I'm a bit confused about how best to get data from two tables.
I have two tables:
redirects
id datetime ip_address browser_agent url_string
link
id alias url created user_id
Links store link data and each time a table is redirected , redirects as a single row for each redirect.
alias in links and url_string in redirects are the same. for example, Dw4 , so the domain will be example.com/Dw4 - redirected to the url field in the links .
What I'm trying to achieve is to select (and count) all the redirects from the redirect table, where url_string matches alias , and then where user_id is the same as the registered user.
I am using Codeigniter.
While I'm trying to find something like this:
$query=$this->db->query("SELECT * " . "FROM links, redirects " . "WHERE links.alias = redirects.url_string");
But Iβm out of luck.
source share