[ale] [OT] Left Join SQL help... -- THANKS!!!!!!
Cade Thacker
linux at cade.org
Sat Apr 5 12:09:07 EST 2003
Sorry it has taken me a couple of days to get back with you all. First off
thanks for all your advise. It was all top notch (just what I expected out
of this group).
So I have finished phase one. If you guys want to see the end result, head
over to http://www.cade.org and click on "health" at the bottom of the
page.
As per the two major points that you all made. The final SQL which is used
for the "Enter Data" portion, was
SELECT name, exercise, food, weight, liquids
FROM person
LEFT JOIN weight ON person.person_id = weight.person_id
AND (weight.date = '2003-04-05' OR weight.date IS NULL)
LEFT JOIN liquids ON person.person_id = liquids.person_id
AND (liquids.date = '2003-04-05' OR liquids.date IS NULL)
LEFT JOIN exercise ON person.person_id = exercise.person_id
AND (exercise.date = '2003-04-05' OR exercise.date IS NULL)
LEFT JOIN food ON person.person_id = food.person_id
AND (food.date = '2003-04-05' OR food.date IS NULL)
WHERE person.person_id = 1
Note the "IS NULL" rather than "= NULL", (thanks greg at turnstep.com)
Also I looked a the suggestions about changing my ERD, the problem is that
weight is an UNSIGNED INT were everything else is a text field, so I can't
do the common table with activity_id (which would have been a lot freakin
easier to query). Is there another way around that, and still abide by the
rules of normalization?
Once again, thanks for all of you all's help.
--cade
On Linux vs Windows
==================
Remember, amateurs built the Ark, Professionals built the Titanic!
==================
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale
More information about the Ale
mailing list