Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7735515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:31:19+00:00 2026-06-01T07:31:19+00:00

Please i need your help with how to include INDEXES in my tables, i’ve

  • 0

Please i need your help with how to include INDEXES in my tables, i’ve read about it in several tutorials but still cant implement it on my database . To increase the efficiency of my database:
I have installed php_apc.dll on the wampserver and it’s faster a bit, I have also tried to avoid the use of SELECT *
in my queries where neccessary. But how to implement INDEX is my problem. I’ll be glad if you can please point out where it’ll be nesseccary to INDEX.

Here is my database schema

  Database: RESULTS
  -------------------

   Table: STUDENTS
   - studentID (int)
   - first_name (varchar)
   - last_name (varchar)
   - other_name (varchar)

   Table: COURSES
   - courseID (int)
   - course_code (varchar)
   - course_title (varchar)
   - course_unit (int)

   Table: SEMESTER
   - semesterID
   - semester_name

   Table: MAINTABLE
   - scoresID (int)
   - courseID (int)
   - studentID (int)
   - semester_name (varchar)
   - session (varchar) 
   - score (int)
   - grade (varchar)
   - remarks (varchar)

Most of my queries revolve round
INSERT INTO MAINTABLE , STUDENTS ….. then SELECT FROM MAINTABLE , STUDENTS and COURSES

Thank you for your patience and time. I most appreciate it.
Thanks.

**EXAMPLES OF QUERIES”

                   $query2 = mysql_query("SELECT       first_name, last_name
        FROM students 
      WHERE matric_no = '".$matric_no."' ");
    ($row2 = mysql_fetch_array($query2)); 

    $query3 = mysql_query("SELECT  SUM(c.        course_unit) AS 'TOTAL'
               FROM    maintable AS m  
           INNER JOIN students AS s ON
                m.matric_no = s.matric_no
          INNER JOIN courses AS c ON
             m.course_code = c.course_code
       WHERE m.matric_no = '".$matric_no."'
          AND m.level = '".$level."'") or 
 die (mysql_error());

             $query4 = mysql_query("SELECT  c.          course_unit, m.score 
         FROM    maintable AS m  
                 INNER JOIN students AS s ON
                      m.matric_no = s.matric_no
                  INNER JOIN courses AS c ON
           m.course_code = c.course_code
      WHERE m.matric_no = '".$matric_no."'
                      AND m.level = '".$level."'") 
      or die (mysql_error()); 

              $query5 = mysql_query("SELECT  c.         course_unit, m.score 
             FROM    maintable AS m  
         INNER JOIN students AS s ON
             m.matric_no = s.matric_no
                     INNER JOIN courses AS c ON
                 m.course_code = c.course_code
     WHERE m.matric_no = '".$matric_no."'")           or die (mysql_error()); 


    $query6 = mysql_query("SELECT  SUM(c.              course_unit) AS 'TOTAL'
                     FROM    maintable AS m  
                      INNER JOIN students AS s ON
                              m.matric_no = s.matric_no
                      INNER JOIN courses AS c ON
                 m.course_code = c.course_code
      WHERE m.matric_no = '".$matric_no."'")           or die (mysql_error());     



            $query7 = mysql_query("SELECT  m.                            course_code AS 'Course Code',        c.course_title AS 'Course Title'
 , c.course_unit AS 'Unit',
  m.score AS 'Score', m.grade AS 'Grade'
                      FROM    maintable AS m  
                      INNER JOIN students AS s ON
                m.matric_no = s.matric_no
                      INNER JOIN courses AS c ON
                 m.course_code = c.course_code
  WHERE m.matric_no = '".$matric_no."'
  AND m.level = '".$level."'") 
   or die (mysql_error());
               $number_cols = mysql_num_fields         ($query7);

            $query8 = mysql_query("SELECT  m.         score, m.course_code 
                      FROM    maintable AS m  
                      INNER JOIN students AS s ON
                              m.matric_no = s.matric_no
                      INNER JOIN courses AS c ON
                 m.course_code = c.course_code
         WHERE m.matric_no = '".$matric_no."'
      AND m.score >= 0 AND m.score < 40 ")         or die (mysql_error());

                   $query9 = mysql_query("SELECT          m.grade, m.course_code 
                      FROM    maintable AS m  
                      INNER JOIN students AS s ON
                              m.matric_no = s.matric_no
                      INNER JOIN courses AS c ON
               m.course_code = c.course_code
         WHERE m.matric_no = '".$matric_no."'
                      AND m.grade = 'AR'") 
    or die (mysql_error());

Please forgive my formating. I typed from a mobile. Thank you for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:31:20+00:00Added an answer on June 1, 2026 at 7:31 am

    You should begin by running all queries with EXPLAIN. That should show you some pointers.

    But if you are asking for a rule of thumb, this would be the general guideline:

    • index columns which are FOREIGN KEY in JOIN statements
    • index all the columns used in WHERE conditions
    • index all the columns used in ORDER BY

    Also there seem to be a lot of VARCHAR searches. Some additional normalization might give beneficial results too. It is easier to search for level_id then for level name.

    Also, as a side note: please stop using the ancient mysql_* function. They are 10+ years old, no longer maintained and the process of making them deprecated had already begun. Instead you should start using prepared statements with PDO or MySQLi. One should’t write new code with mysql_* API.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please i need your help. I'm performing SUM() on a column for course_unit, but
Please i need your help with my script. Whenever i include AND maintable.semester_name =
Please I need your help with my script. I'm trying to insert values into
Please help! I need to produce a Crystal Report with multiple data columns, but
please I need your help with a Linq expression: I have nested objects with
guys i need your help, please tell me how can i pass 2 different
I am new to programming please help me. I need to read a file
I'm new to this ExpandableListView and I desperately need your help please. I'm using
I really need your help. I tried everything but the result is always the
Please I need your help with the display of a page in my App.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.