drewtemp 0 Newbie Poster

Hey guys,

I need a "little" help with a query. I'm trying to pull information regarding referrals from search engines which grab the keywords. For example, two people search for foobar and another searches for barfoo. I would need the results returned similar to this:

Hits   |      Page URL       |   Keywords
=========================
  3    | http://url.com/     |         2

Here is the query I currently have which fails miserably.

SELECT A.page_url, A.page_title, B.total_terms, B.hits
	FROM visits A
	INNER JOIN
		(SELECT search_terms, search_temrs, COUNT(*) AS hits
			FROM searches
			GROUP BY url_path, search_terms
		) B
		ON A.page_url = B.url_path
	GROUP BY A.page_url, B.search_terms

Which returns:

HITS 	PAGE_TITLE 	PAGE_URL 	TOTAL_TERMS
1 	 1 	 	page 	 	http://url.com/ 	 	1
2 	 2 	 	page 	 	http://url.com/  		2

Help is greatly appreciated. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.