Jump to content

How to write a query?

- - - - -

  • Please log in to reply
3 replies to this topic

#1
newbie noob

newbie noob

    Newbie

  • Members
  • Pip
  • 2 posts
its a noob project , i haven't been into any kind of courses
anyway the project is about saving the grades of student
this is my database

Attached File  Untitled.jpg   86.43K   37 downloads

i guess the way it works is understandable for most of u

my question is , how can i write a query which returns all the courses from the course table of a specific name in the table people.name
thank u very very much !

i would really appreciate any other notes , as i said I am a newbie noob ,

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
SELECT COURSES.* FROM COURSES INNER JOIN PEOPLECREDITS ON COURSES.COURSE=PEOPLECREDITS.COURSE WHERE PEOPLECREDITS.NAME='Bob';

Side note: you should probably have a foreign key relation between COURSES and PEOPLECREDITS.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
newbie noob

newbie noob

    Newbie

  • Members
  • Pip
  • 2 posts

WingedPanther said:

SELECT COURSES.* FROM COURSES INNER JOIN PEOPLECREDITS ON COURSES.COURSE=PEOPLECREDITS.COURSE WHERE PEOPLECREDITS.NAME='Bob';

Side note: you should probably have a foreign key relation between COURSES and PEOPLECREDITS.

i appreciate ur fast reply
the query u gave me wont work , anyhow i guess the problem is with my explanation
the project is about helping students in specific university's and specializations to calculate their gpa
the table courses contains all of the courses of all universitys and specializations , if the students chooses a course it will be added to the peoplecredits table ,however the subject is i want to return all of the courses that a student hasnt taken yet ,
selecting course from courses where people.credits!=courses.course and peoplecredits.name (or people.name) = 'bob';
is it well explained or do u need any further information ?

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
It looks like you will need to use a left outer join, but I'm not clear on what the data will look like, so can't write the query. Can you give sample data to illustrate what you want?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users