pls find the error in this sql

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    pls find the error in this sql

    hi admin, i have a error in this sql. i can add a subject in the subject table., bt agian i cant update a existing details in subject table. Its only there in previous data, likewise attendance, student details, examination all tables having same error. pls solve frds,.......... this is my college project... help meeeeeeeeee alllllllll
    PHP Code:
    --
    -- 
    Database: `studentinfo`
    --

    -- --------------------------------------------------------

    --
    -- 
    Table structure for table `administrator`
    --

    CREATE TABLE IF NOT EXISTS `administrator` (
    `
    adminidbigint(4NOT NULL AUTO_INCREMENT,
    `
    passwordvarchar(50NOT NULL,
    `
    adminnamevarchar(80NOT NULL,
    `
    addresstext NOT NULL,
    `
    contactnovarchar(25NOT NULL,
    PRIMARY KEY (`adminid`)
    ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=124 ;

    --
    -- 
    Dumping data for table `administrator`
    --


    -- --------------------------------------------------------

    --
    -- 
    Table structure for table `attendance`
    --

    CREATE TABLE IF NOT EXISTS `attendance` (
    `
    attidbigint(4NOT NULL AUTO_INCREMENT,
    `
    studidvarchar(20NOT NULL,
    `
    subidbigint(4NOT NULL,
    `
    totalclassesint(2NOT NULL,
    `
    attendedclassesint(2NOT NULL,
    `
    percentagedouble(4,2NOT NULL,
    `
    commenttext NOT NULL,
    PRIMARY KEY (`attid`),
    KEY `studid` (`studid`),
    KEY `subid` (`subid`)
    ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=;

    --
    -- 
    Dumping data for table `attendance`
    --

    INSERT INTO `attendance` (`attid`, `studid`, `subid`, `totalclasses`, `attendedclasses`, `percentage`, `comment`) VALUES
    (6'1'1121299.99'sfsdf');

    -- --------------------------------------------------------

    --
    -- 
    Table structure for table `contact`
    --

    CREATE TABLE IF NOT EXISTS `contact` (
    `
    contactidbigint(4NOT NULL AUTO_INCREMENT,
    `
    namevarchar(25NOT NULL,
    `
    emailidvarchar(30NOT NULL,
    `
    contactnovarchar(20NOT NULL,
    `
    subjectvarchar(20NOT NULL,
    `
    messagetext NOT NULL,
    PRIMARY KEY (`contactid`)
    ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=;

    -- --------------------------------------------------------

    --
    -- 
    Table structure for table `course`
    --

    CREATE TABLE IF NOT EXISTS `course` (
    `
    courseidbigint(4NOT NULL AUTO_INCREMENT,
    `
    coursenamevarchar(40NOT NULL,
    `
    commenttext NOT NULL,
    `
    coursekeyvarchar(15NOT NULL,
    PRIMARY KEY (`courseid`)
    ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=;

    --
    -- 
    Dumping data for table `course`
    --

    INSERT INTO `course` (`courseid`, `coursename`, `comment`, `coursekey`) VALUES
    (1'Bachelor of Arts''This Course is related to Arts field.''BA'),
    (
    2'Bachelor of Commerce''This course is related to commerce field.''BCom'),
    (
    3'Bachelor of Bussiness Management''This course is related to Bussiness field.''BBM'),
    (
    4'Bachelor of Science''This field is related to science field.''BSc'),
    (
    5'Bachelor of Computer Application''This field is related to computer field.''BCA'),
    (
    6'Bachelor of Social Work''This field is related to social welfare field.''BSW');

    -- --------------------------------------------------------

    --
    -- 
    Table structure for table `examination`
    --

    CREATE TABLE IF NOT EXISTS `examination` (
    `
    examidbigint(4NOT NULL AUTO_INCREMENT,
    `
    studidvarchar(20NOT NULL,
    `
    subidbigint(4NOT NULL,
    `
    courseidbigint(4NOT NULL,
    `
    internaltypevarchar(20NOT NULL,
    `
    maxmarksint(2NOT NULL,
    `
    scoredint(2NOT NULL,
    `
    percentagefloat NOT NULL,
    `
    resulttext NOT NULL,
    PRIMARY KEY (`examid`),
    KEY `subid` (`subid`),
    KEY `studid` (`studid`),
    KEY `courseid` (`courseid`)
    ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;

    -- --------------------------------------------------------

    --
    -- 
    Table structure for table `lectures`
    --

    CREATE TABLE IF NOT EXISTS `lectures` (
    `
    lecidbigint(4NOT NULL AUTO_INCREMENT,
    `
    passwordvarchar(50NOT NULL,
    `
    courseidbigint(4NOT NULL,
    `
    lecnamevarchar(50NOT NULL,
    `
    gendervarchar(50NOT NULL,
    `
    addressvarchar(100NOT NULL,
    `
    contactnovarchar(15NOT NULL,
    PRIMARY KEY (`lecid`),
    KEY `courseid` (`courseid`)
    ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=;

    --
    -- 
    Dumping data for table `lectures`
    --

    INSERT INTO `lectures` (`lecid`, `password`, `courseid`, `lecname`, `gender`, `address`, `contactno`) VALUES
    (1'0cc175b9c0f1b6a831c399e269772661'5'geetha''Female''fgv''9876543211');

    -- --------------------------------------------------------

    --
    -- 
    Table structure for table `semester`
    --

    CREATE TABLE IF NOT EXISTS `semester` (
    `
    semidbigint(4NOT NULL AUTO_INCREMENT,
    `
    semestervarchar(25NOT NULL,
    `
    commenttext NOT NULL,
    PRIMARY KEY (`semid`)
    ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=;

    -- --------------------------------------------------------

    --
    -- 
    Table structure for table `studentdetails`
    --

    CREATE TABLE IF NOT EXISTS `studentdetails` (
    `
    studidvarchar(25NOT NULL,
    `
    studfnamevarchar(20NOT NULL,
    `
    studlnamevarchar(20NOT NULL,
    `
    fathernamevarchar(25NOT NULL,
    `
    gendervarchar(20NOT NULL,
    `
    addressvarchar(100NOT NULL,
    `
    contactnovarchar(20NOT NULL,
    `
    courseidbigint(4NOT NULL,
    `
    semestervarchar(20NOT NULL,
    `
    dobdate NOT NULL,
    PRIMARY KEY (`studid`),
    KEY `courseid` (`courseid`)
    ENGINE=InnoDB DEFAULT CHARSET=latin1;

    --
    -- 
    Dumping data for table `studentdetails`
    --

    INSERT INTO `studentdetails` (`studid`, `studfname`, `studlname`, `fathername`, `gender`, `address`, `contactno`, `courseid`, `semester`, `dob`) VALUES
    ('1''sam''a''asdf''Male''xcv''452757855'5'1''1996-02-09');

    -- --------------------------------------------------------

    --
    -- 
    Table structure for table `subject`
    --

    CREATE TABLE IF NOT EXISTS `subject` (
    `
    subidbigint(4NOT NULL AUTO_INCREMENT,
    `
    subnamevarchar(20NOT NULL,
    `
    courseidbigint(4NOT NULL,
    `
    lecidbigint(4NOT NULL,
    `
    subtypevarchar(25NOT NULL,
    `
    semestervarchar(25NOT NULL,
    `
    commenttext NOT NULL,
    PRIMARY KEY (`subid`),
    KEY `courseid` (`courseid`)
    ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=;

    --
    -- 
    Dumping data for table `subject`
    --

    INSERT INTO `subject` (`subid`, `subname`, `courseid`, `lecid`, `subtype`, `semester`, `comment`) VALUES
    (1'English'10'Language''1''fhjfbg'),
    (
    3'Accounting'30'Theory''1''jsjk');

    --
    -- 
    Constraints for dumped tables
    --

    --
    -- 
    Constraints for table `attendance`
    --
    ALTER TABLE `attendance`
    ADD CONSTRAINT `attendance_ibfk_1FOREIGN KEY (`subid`) REFERENCES `subject` (`subid`) ON DELETE CASCADE ON UPDATE CASCADE,
    ADD CONSTRAINT `attendance_ibfk_2FOREIGN KEY (`studid`) REFERENCES `studentdetails` (`studid`) ON DELETE CASCADE ON UPDATE CASCADE;

    --
    -- 
    Constraints for table `examination`
    --
    ALTER TABLE `examination`
    ADD CONSTRAINT `examination_ibfk_1FOREIGN KEY (`studid`) REFERENCES `studentdetails` (`studid`) ON DELETE CASCADE ON UPDATE CASCADE,
    ADD CONSTRAINT `examination_ibfk_2FOREIGN KEY (`courseid`) REFERENCES `course` (`courseid`) ON DELETE CASCADE ON UPDATE CASCADE,
    ADD CONSTRAINT `examination_ibfk_3FOREIGN KEY (`subid`) REFERENCES `subject` (`subid`) ON DELETE CASCADE ON UPDATE CASCADE;

    --
    -- 
    Constraints for table `lectures`
    --
    ALTER TABLE `lectures`
    ADD CONSTRAINT `lectures_ibfk_1FOREIGN KEY (`courseid`) REFERENCES `course` (`courseid`) ON DELETE CASCADE ON UPDATE CASCADE;

    --
    -- 
    Constraints for table `studentdetails`
    --
    ALTER TABLE `studentdetails`
    ADD CONSTRAINT `studentdetails_ibfk_1FOREIGN KEY (`courseid`) REFERENCES `course` (`courseid`) ON DELETE CASCADE ON UPDATE CASCADE;

    --
    -- 
    Constraints for table `subject`
    --
    ALTER TABLE `subject`
    ADD CONSTRAINT `subject_ibfk_1FOREIGN KEY (`courseid`) REFERENCES `course` (`courseid`) ON DELETE CASCADE ON UPDATE CASCADE
    Last edited by arnage; 20.09.13, 21:17.

    #2
    which college are you at?

    Comment


      #3
      INSERT INTO `attendance` (`attid`, `studid`, `subid`, `totalclasses`, `attendedclasses`, `percentage`, `comment`) VALUES
      (6, '1', 1, 12, 12, 99.99, 'sfsdf');

      brother if you used any field with auto increment so you have to use null value for it in your code you used attid as auto inc but you used a value for this i think this is the wrong

      Comment

      Working...
      X