PHP Web Host - Quality Web Hosting For All PHP Applications $35/month $250/year (Unlimited) - $25/month - 200,000 impressions - Your Ad Could be Here - Click For Details
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
Donovan
Client


Joined: Oct 07, 2003
Posts: 691
Location: Ohio

PostPosted: Wed Jan 16, 2008 12:50 pm Reply with quote Back to top

I need to find if any students in my imported table "atlas_tl_session_grade_import" do not yet belong to a group in the "atlas_tl_group_students"

The import table contains the unique field UID
The student table has both SOMS_KEY and UID.
The student group table contain the unique field SOMS_KEY and Group_ID
The group table has Group_ID

I am attempting a sub query to do this but don't know if I'm on the right track.

Code:
SELECT a.UID FROM atlas_tl_session_grade_import a
WHERE a.UID NOT IN (SELECT a.UID a.SOMS_KEY FROM atlas_tl_students a 
JOIN atlas_tl_group_students b ON (a.SOMS_KEY = b.SOMS_KEY)
JOIN atlas_tl_groups c ON (b.Group_ID = c.Group_ID)) 


I then will do a sql_numrows

then

Code:

if ( $group_total > 0 ) {
OpenTable();
echo"<tr><td>There are student grades from this import who have not yet been assigned to a group.</td></tr>";
echo"<tr><td>Please ensure all students for this class year have been assigned to their TL group.</td></tr>";
echo"<tr><td><input type=\"button\" value=\"Back\" onClick=\"history.go(-1)\"></td></tr>";
Closetable();
die();
} else {


ect
View user's profile Send private message Visit poster's website ICQ Number
montego
Site Admin


Joined: Aug 29, 2004
Posts: 7487
Location: Arizona

PostPosted: Wed Jan 16, 2008 4:36 pm Reply with quote Back to top

Not 100% sure on the whole SQL, but the concept, I think, is sound. However, you can only return a.UID in your subselect since that is what you are comparing too (i believe) and you might also want to do a select distinct to remove dups.
View user's profile Send private message Visit poster's website
Donovan
Client


Joined: Oct 07, 2003
Posts: 691
Location: Ohio

PostPosted: Thu Jan 17, 2008 7:30 am Reply with quote Back to top

Thanks
View user's profile Send private message Visit poster's website ICQ Number
mars
Regular
Regular


Joined: Jul 08, 2006
Posts: 89
Location: Bloomsburg,Pennsylvania

PostPosted: Thu Jan 17, 2008 1:58 pm Reply with quote Back to top

A simple left join should do what you are looking for, then you can just do a count of the results to see if it is greater than 0
I used the main user table and the journal table as an example for you here.

Code:

SELECT nuke_users.user_id, nuke_users.name, nuke_users.username, nuke_users.user_email
FROM nuke_users LEFT JOIN nuke_journal ON nuke_users.username = nuke_journal.aid
WHERE (((nuke_journal.aid) Is Null))
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2008 by Raven
Proud to be listed at Lobo Links Web Directory

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::

:: fisubice Theme Recoded To 100% W3C CSS & HTML 4.01 Transitional Compliance by Raven and 64bitguy ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum