title: MySQL/SQL query for multiple tables
body: <p>I have multiple tables and I’m trying to do a query on searching student by their IDs “studentID”. When I run the query below, MySQL or SQL Server freezes(loading…). Any suggestion? Not all the tables are listed. Thanks.</p>
  
  <p><strong>TABLES:</strong></p>
  
  <p><strong><em>students</em></strong></p>
  
  <pre><code>•   studentsID  Int Pkey
  •   Fname   string
  •   Lname   string …    
  •   studentsGender  Int Fkey
  •   studentsGender  int Fkey
  •   studentsRezAddressID    int Fkey
  •   studentsBirthID int Fkey
  •   studentsParentsID   int Fkey
  </code></pre>
  
  <p><strong><em>student_address:</em></strong></p>
  
  <pre><code>•   RezAddressID    Int Pkey
  •   RezStreet   Varchar
  •   RezCity Int Fkey
  •   RezState    int Fkey
  •   RezDistrict int Fkey
  •   RezCountry  int Fkey
  •   RezZipcode  int
  </code></pre>
  
  <p><strong><em>student_edu:</em></strong></p>
  
  <pre><code>•   eduID   Int Pkey
  •   eduAcadYear Int Fkey
  •   eduAdmitionTest Varchar
  •   scholarship Varchar
  •   study   Int Fkey
  •   classroom   Int Fkey
  •   studentStatus   Int Fkey
  •   testStatus  Int Fkey
  •   additionalInfo  Varcha
  </code></pre>
  
  <p>r</p>
  
  <p><strong><em>Academic_years</em></strong></p>
  
  <pre><code>academicID  Int Pkey
  academicYear    VarChar
  </code></pre>
  
  <p><strong><em>Cities</em></strong></p>
  
  <pre><code>cityID  Int Pkey
  city    VarChar
  </code></pre>
  
  <p><strong><em>Countries</em></strong></p>
  
  <pre><code>countryID   Int Pkey
  country VarChar
  </code></pre>
  
  <p><strong><em>Countries</em></strong></p>
  
  <pre><code>districtsID Int Pkey
  district    VarChar
  </code></pre>
  
  <p><strong><em>ethnicities</em></strong></p>
  
  <pre><code>ethnicityID Int Pkey
  ethnicity   VarChar
  </code></pre>
  
  <p><strong><em>grads</em></strong></p>
  
  <pre><code>gradID  Int Pkey
  grad    VarChar
  
  SELECT
  students.studentsID,
  students.studentsLname,
  students.studentsMname,
  students.studentsFname,
  students.studentsMobile,
  students.studentEmail,
  students.joined_date,
  genders.gender,
  ethnicities.ethnicity,
  races.races,
  student_address.RezStreet,
  student_address.RezZipcode,
  grads.grad,
  rooms.rooms,
  studies.study,
  student_edu.additionalInfo,
  student_status.student_status,
  academic_years.academicYear,
  teststatus.testStatus,
  student_edu.scholarship,
  student_birth_place.birthDate,
  cities.city,
  states.states,
  countries.country,
  districts.district   
  FROM
      (
          students,
          student_edu,
          student_address,
          studies,
          rooms,
          student_status,
          teststatus,
          academic_years,
          grads,
          races,
          genders,
          ethnicities,
          student_birth_place,
          districts,
          cities,
          states,
          countries
      )
  WHERE students.studentsID = “00012” ;
  </code></pre>
  
  <p>I did Use JOIN Statement as well, but the issue still persisting.</p>
  
  <blockquote>
    <p><code>INNER JOIN grads As studGrad ON studentsEduID = student_edu.eduID
    INNER JOIN studies AS studyOption ON student_edu.study = studies.studiesID 
    INNER JOIN rooms AS classRoom ON student_edu.classroom = rooms.roomsID
    INNER JOIN student_status AS stat ON student_edu.studentStatus = student_status.student_statusID
    INNER JOIN testStatus AS admiTest ON student_edu.testStatus = testStatus.testStatusID
    INNER JOIN student_address AS studAddre ON students.studentsRezAddressID = student_address.RezAddressID
    INNER JOIN student_birth_place AS stubBirth ON students.studentsBirthID = student_birth_place.birthID 
    INNER JOIN cities AS ville ON student_address.RezCity = cities.cityID
    INNER JOIN states AS province ON student_address.RezState = states.statesID 
    INNER JOIN districts AS commune ON student_address.RezDistrict = districts.districtsID
    INNER JOIN countries AS pays ON student_address.RezCountry = countries.countryID</code></p>
  </blockquote>