Let's say I have two tables: one stores links and contains a link_id column, and the other stores info on how many times a particular link has been clicked and it contains a count column and the link_id column. What would be the query to the table in order to retrieve all the links along with the info?
+1
A:
something like this
SELECT l.link_id, l.link, s.count
FROM link l
LEFT JOIN stats s
ON l.link_id = s.link_id
should get you all the ids, links (regardless of whether they have an entry in the stats table) and the number of times they've been clicked
Dave
2010-10-17 11:21:51
A:
Say tables are tab1 and tab2.
query: select link,count
from tab1 inner join tab2 using(link_id)
Sadat
2010-10-17 11:24:11