This topic is locked

Help with generating a query

1/24/2010 7:09:13 PM
PHPRunner General questions
R
Rens1976 author

Hi everyone

I'm real new to SQL and phprunner. I need some help with a query I'm trying to wright.
I have a table (Eating). The fields are 'ID' 'NameID' 'Date1' 'Breakfast' 'Lunch' 'Dinner'

ID is an autonumber

Name is text

Date1 is a date

Breafast, lunch and dinner are check boxes.
I have a complex set of relationships set up.

  • The 'Eating' table is subordinate to the 'Client Name'table. The related field is 'NameID'.
  • I have created 3 alternate views to the 'Eating' Table. They are called 'AM' 'PM' and 'Night'. I have done this so the enduser sees them as child records on the 'Client Name' list. When the enduser clicks on the 'AM' child record in the 'Client Name' list they are given 2 fields to complete: 'Date1' and 'Breakfast'. Similarly when 'PM' child record is selected from the 'Client Name' list the enduser completes: 'Date1' and 'Lunch'. Then the same occurs for 'Night'.
    The end user ticks the check box to say they have eaten breakfast, lunch and/or dinner. They may have eaten all three or none at all.

    I need a query that will generate a report to tell me who has NOT had anything to eat for 3 or more days.

    I would like to keep my current database architecture however if this is the reason a query can not be generate I'm happy to consider something different to get the end result.

    Thanks in advance for your assistance.

J
Jane 1/26/2010

Hi,
use subqueries to select all names for which number of records with empty date is more then 3.

Here is a helpful link:

http://dev.mysql.com/doc/refman/5.0/en/subqueries.html

R
Rens1976 author 2/6/2010



Hi,
use subqueries to select all names for which number of records with empty date is more then 3.

Here is a helpful link:

http://dev.mysql.com/doc/refman/5.0/en/subqueries.html



Thanks Jane