i have 4 tables in a db, to allow users rate certain recipes. they might not rate all recipes at one time. they might even go back and rate a recipe more than one time. there will also be at least 1, and up to 4 kids participating in voting for each recipe.
i would like to determine the first 100 moms to rate all X recipes using the date of submission of the vote of the final recipe as qualifier. (meaning a mom would get added to the list of 100 after she rates all recipes from the recipes table)
it seems it will either take a complex nested query, or several queries mixed in with php
below are the 4 tables.
any help would be appreciated.
recipes_db
-- recipe_id
-- recipe_name
mom_form
-- user_id
-- firstname
-- lastname
-- phonenumber
-- address
-- city
-- state
-- zipcode
-- timestamp
mom_comments
-- comment_id
-- user_id
-- recipe_id
-- favorite_recipe
-- moms_comments
-- childname1
-- childage1
-- child_comments1
-- childname2
-- childage2
-- child_comments2
-- childname3
-- childage3
-- child_comments3
-- childname4
-- childage4
-- child_comments4
-- timestamp
mom_votes
-- votes_id
-- rating
-- user_id
-- recipe_id
-- timestamp
4 1863
You posted your assignment, fine. But did you also read the forum guideline?
So what's your question? How can we help?
Just post the SQL or code where you have difficulties with.
i have 4 tables in a db, to allow users rate certain recipes. they might not rate all recipes at one time. they might even go back and rate a recipe more than one time. there will also be at least 1, and up to 4 kids participating in voting for each recipe.
i would like to determine the first 100 moms to rate all X recipes using the date of submission of the vote of the final recipe as qualifier. (meaning a mom would get added to the list of 100 after she rates all recipes from the recipes table)
it seems it will either take a complex nested query, or several queries mixed in with php
below are the 4 tables.
any help would be appreciated.
recipes_db
-- recipe_id
-- recipe_name
mom_form
-- user_id
-- firstname
-- lastname
-- phonenumber
-- address
-- city
-- state
-- zipcode
-- timestamp
mom_comments
-- comment_id
-- user_id
-- recipe_id
-- favorite_recipe
-- moms_comments
-- childname1
-- childage1
-- child_comments1
-- childname2
-- childage2
-- child_comments2
-- childname3
-- childage3
-- child_comments3
-- childname4
-- childage4
-- child_comments4
-- timestamp
mom_votes
-- votes_id
-- rating
-- user_id
-- recipe_id
-- timestamp
i was wondering if anyone might be able to determine a complex query based on the tables above, or if a concensus might be to break it up into smaller queries, the results of which might then be examined together with php. my query: find the first 100 moms who rate X recipes as determined by the timestamp of the last (last for that user) submitted rating. the user might not rate all recipe in one sitting. they might rate them over several days.
So if there are 3 recipes to rate, a user enters (or doesn't enter) the list of 100 according to the timestamp of the third entry.
as i mentioned previously, i'm not sure if this can be accomplished in large complex (nested?) query, or it will require several separate queries.
i haven't really written any queries yet. I have written a few small queries that might do one part or other of the larger goal. the one or two attempts i have made at a large unified query, have not at all been successful and are not yet even worth posting.
thanks for any help.
i was wondering if anyone might be able to determine a complex query based on the tables above, or if a concensus might be to break it up into smaller queries, the results of which might then be examined together with php. my query: find the first 100 moms who rate X recipes as determined by the timestamp of the last (last for that user) submitted rating. the user might not rate all recipe in one sitting. they might rate them over several days.
So if there are 3 recipes to rate, a user enters (or doesn't enter) the list of 100 according to the timestamp of the third entry.
as i mentioned previously, i'm not sure if this can be accomplished in large complex (nested?) query, or it will require several separate queries.
i haven't really written any queries yet. I have written a few small queries that might do one part or other of the larger goal. the one or two attempts i have made at a large unified query, have not at all been successful and are not yet even worth posting.
thanks for any help.
You can write all in one huge SQl, but I wouldn't do it. Because it makes the program very hard to understand for people who come after you and need to change the code. I have enough experience that I can tell you that even you would not understand your own SQL anymore if you look at it a year later or so. Also it makes it run very slow and puts a heavy load on the database. Having many small SQLs instead are much, much better.
Just develop them and post them one by one if you have problems with them.
I can help you if you are stuck, for example if you don't know how to code the "find the first 100 moms" condition.
Then I would answer you, make the SQL that gets them all, let's call it "yourSqlStateme nt " and wrap around: - select * from ( yourSqlStatement ) where rownum <= 100;
But I will not give you complete solutions, only help. Because it's your work and you will not learn otherwise.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Simon |
last post by:
Hi,
I am having a little problem with my PHP - MySQl code, I have two tables
(shown below) and I am trying populate a template page with data from both.
<disclaimer>Now I would like to say my skills, especially with MySQL are
rudimentary</disclaimer> However my code (link below) fails, the nested
database call does not return any data and this has me stumped. Any help
will be much appreciated.
Many thanks in advance
|
by: Colman |
last post by:
Howdy all!
I guess I'm a newbie, because I am stumped (or maybe just too durned
tired). Here's what I got...
CREATE TABLE `nodecat_map` (
`nodecat_id` mediumint(8) unsigned NOT NULL auto_increment,
`nodecat_cat_id` mediumint(8) unsigned NOT NULL default '0',
`nodecat_node_id` mediumint(8) unsigned NOT NULL default '0',
PRIMARY KEY (`nodecat_id`),
|
by: Marcus |
last post by:
Hi
I have a very complex sql query and a explain plan. I found there is a
full table scan in ID=9
9 8 TABLE ACCESS (FULL) OF 'F_LOTTXNHIST'
(Cost=84573 Card=185892 Bytes=7063896)
How can I correlate which part of the SQL statement is running on full
table scan. Please see below for the code and explain plan
SQL Code
|
by: Mike Chirico |
last post by:
Interesting Things to Know about MySQL
Mike Chirico (mchirico@users.sourceforge.net)
Copyright (GPU Free Documentation License) 2004
Last Updated: Mon Jun 7 10:37:28 EDT 2004
The latest version of this document can be found at:
http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
|
by: Steve Jorgensen |
last post by:
Mailing List management is a good example of a case where my conundrum arises.
Say there is a m-m relationship between parties and groups - anyone can be a
member of any combintation of groups. Now, let's say the user wants to be
able to send mailings to people who have various combinations of membership
and non-membership in those groups.
Here's a medium-complex example: (Knitting Group or Macrame Group) and Active
Contact and Mailing...
| |
by: Robert W. |
last post by:
I have built several kinds of complex classes that I work with in my program.
Storing them to disk is no problem because I just pass the instantiated
object to a SaveData method, accepting it as a generic "object". Then I use
reflection to iterate through the object and save the data.
But loading the data from disk seems to be anything but generic. I have
several challenges with this but here's one of the first:
public void OpenData...
|
by: Good Man |
last post by:
Hi there
I've noticed some very weird things happening with my current MySQL setup
on my XP Laptop, a development machine.
For a while, I have been trying to get the MySQL cache to work. Despite
entering the required lines to "my.ini" (the new my.cnf) through notepad
AND MySQL Administrator, the cache does not work.
So, today I took a peek at the 'Health' tab in MySQL Administrator.
|
by: bugboy |
last post by:
I'm experimenting with the "Nested Set" type structure for holding hierarchical data in mysql. This is my refrence:
http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
When i run the following query on the sample database it doesn't use the index for the 'parent' table and checks the range for every single row... When i use EXPLAIN SELECT it shows an "all" type which is bad because in practice all my hierarchys will be...
|
by: BUmed |
last post by:
Ok let me start from the start. I have a form that has question in it and the person chooses 0 1 2 -99 for each. The form then needs to add up the numbers for the sub categories in the form. For example question 1-8 deal with communication and can rang from 0 to 16 points. The problem that I'm running into is the -99 which is needed to denote that the question does not ably. So if one of the communication questions is NA then it will make the...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |