[thelist] SQL multiple Joins?

Tris beertastic at gmail.com
Thu Nov 15 08:25:24 CST 2007


Is it possible to have multiple joins..

Ont eh query below. it failes.. Buuuut, if I limit it to one join, it
works great..
My database logs transactions and I'm trying to produce a report that
shows each transaction total, within a certain period.. (Oct and sept
so far..)

but it's cfalling over..
Anyhoo, off to google... race you!

============

SELECT
	 SUM(activitiesSep.points) as sepPoints
	,SUM(activitiesOct.points) as octPoints
	,users.ID
	,users.Username
	,users.Password
	,users.Name
	,users.Company
	,users.Address1
	,users.Address2
	,users.Address3
	,users.Address4
	,users.Address5
	,users.Postcode
	,users.Email
	,users.CustomerType
	,users.Active
	,users.LogIns
	,users.GAURef
	,users.JRRef
	,users.GAUMember
	,users.GAUContact
	,users.RegForm
	,users.Created
	,users.Updated

FROM `users`

RIGHT JOIN `activities` as `activitiesSep` on
	activitiesSep.UserID = users.ID
WHERE activitiesSep.`Timestamp` >= '1188604800' AND
activitiesSep.`Timestamp` <= '1191196799'

RIGHT JOIN `activities` as `activitiesOct` on
	activitiesOct.UserID = users.ID
WHERE activitiesOct.`Timestamp` >= '1191196800' AND
activitiesOct.`Timestamp` <= '1193875199'

GROUP BY users.ID

================

-- 
Give a man a fish and he'll feed himself for a day.
Give a man a religion and he'll starve to death praying for a fish.
Anon

`We are what we pretend to be, so we must be careful what we pretend to be.`
Kurt Vonnegut

`When a person can no longer laugh at himself, it is time for others
to laugh at him.`
Thomas Szasz



More information about the thelist mailing list