Author Topic: urgent help needed for mysql selection problem  (Read 107 times)

cogga28

  • Regular Member
  • **
  • Posts: 75
  • Karma: +0/-0
    • View Profile
urgent help needed for mysql selection problem
« on: February 03, 2012, 07:59:21 AM »

hi people i am trying to select all userID where the userID is not in the markerID.
what happens is that when a user completes a test a userID is selected at random then assigned as the markerID this part i can do the problem is that sometimes the test is assigned to a user to be marked more than once so i need to check if that user is already marking a test.
the database code is below and below that is the query so far.

Code: [Select]

create table User
(userID INT NOT NULL auto_increment,
userName varchar (25),
firstName varchar (25),
lastName varchar (25),
member_Type varchar (10),
password text,
        primary key (userID));

insert into user (userName, firstName, lastName, member_Type, password)
values ("Admin", "Admin","Admin","Staff","6e13f95656485e63cd20926b74c62b97");

create table Class
(classID INT NOT NULL auto_increment,
className varchar (15),
userID int,
        teacherID int,
academicYearStart year,
academicYearEnd year,
        primary key (classID),
foreign key (userID) references User (userID));

create table Test
(testID INT NOT NULL auto_increment,
testName varchar (25),
className varchar (15),
        questions varchar(10000),
score varchar (100),
answers varchar(25000) ,
deadline varchar (12),
        primary key (testID));

create table Result
(resultID INT NOT NULL auto_increment,
userID int,
testID int,
markerID int,
score varchar(100),
testAnswers varchar (25000),
flag enum ("yes","no"),
primary key(resultID),
foreign key (userID) references User (userID),
foreign key (testID) references Test (testID));



PHP Code: [Select]


// select random sudent from class to mark test
$qry mysql_query ("SELECT * FROM Class
WHERE Class.userID != '$_SESSION[SESS_MEMBER_ID]' AND Class.className ='$testClass'
ORDER BY RAND()
LIMIT 1"
);