Welcome to WebmasterWorld Guest from 54.161.25.142

Forum Moderators: open

Message Too Old, No Replies

mySQL query for 3 tables

     
12:49 pm on Jan 31, 2010 (gmt 0)

5+ Year Member



I want to write an SQL statement that counts the number of adviews where advertiser = 1

SELECT COUNT(a.adview_id) FROM {adviews} a JOIN {joblist} j
WHERE j.advid = '1'

But that doesnt seem to work. What is the best way to do this?

CREATE TABLE IF NOT EXISTS {joblist} (
jobid INT(10) NOT NULL AUTO_INCREMENT,
advid INT(10) NOT NULL DEFAULT 0,
PRIMARY KEY jobid (jobid))

CREATE TABLE IF NOT EXISTS {advertisers} (
advid INT(10) NOT NULL AUTO_INCREMENT,
PRIMARY KEY advid (advid))

CREATE TABLE IF NOT EXISTS {adviews} (
adview_id BIGINT NOT NULL AUTO_INCREMENT,
jobid INT(10) NOT NULL,
referer VARCHAR(250) NOT NULL DEFAULT '',
browser_ip VARCHAR(15) NOT NULL DEFAULT '',
datecreated INT(11) NOT NULL DEFAULT 0,
uri VARCHAR(250) NOT NULL DEFAULT '',
username VARCHAR(96) NOT NULL DEFAULT '',
PRIMARY KEY (adview_id)}

7:44 pm on Jan 31, 2010 (gmt 0)

10+ Year Member



SELECT COUNT(a.adview_id)
FROM adviews a JOIN joblist j
ON a.adview_id = j.adview_id
WHERE j.advid = '1'
12:04 pm on Feb 3, 2010 (gmt 0)

5+ Year Member



thanks heaps, works now.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month