Options

Please Help with my SQL misery!

nelnel Member Posts: 2,859 ■□□□□□□□□□
Basically at uni im doing Database analysis.
Ive never done any in my life and have had to learn it from scratch in 6 weeks (did i mention i cant wait to finish uni!) which ive found the whole topic difficult to take in due to the high level of things to take in like the 50 different names they have to call a "row" - ok so not 50 but pretty close haha.

anyhow... for my course work i basically have to query a database and complete dozens and dozens of questions using queries. now ive done all the basics but when it comes to the joins, subselects, views and outer joings im starting to get confused about writting the query i need to get the answer, i dont know why but i cant get my head around what the syntax for the query would be.

heres an example:

List the employee surname, forenames, and course for each time an employee attended a course at which no other colleague was present.

i know its vague because you cant see the tables etc but for some reason i look at the Q and think WTF!

Any tips from you pro's out there?

By the way asking the lecturer's for help is a waste of time, its all basically DIY! i would have more joy asking the russians for there government secrets than i would getting answers out of these lot!
Xbox Live: Bring It On

Bsc (hons) Network Computing - 1st Class
WIP: Msc advanced networking

Comments

  • Options
    BeaverC32BeaverC32 Member Posts: 670 ■■■□□□□□□□
    It's difficult to offer assistance without a little more information...table structures are a must if we are to be of any assistance. Are you looking for the answers to your questions, or for an understanding of how inner joins, outer joins, views, subqueries, etc work?
    MCSE 2003, MCSA 2003, LPIC-1, MCP, MCTS: Vista Config, MCTS: SQL Server 2005, CCNA, A+, Network+, Server+, Security+, Linux+, BSCS (Information Systems)
  • Options
    NetstudentNetstudent Member Posts: 1,693 ■■■□□□□□□□
    I agree...It's hard to even begin to think about a query structure without knowing the tables, tuples and attributes. We would at least need a schema...

    With that example, you would probably have a student table with a student ID as the Primary key with a many to many relation to another course table.Many students can take many courses. The course table might have the course ID as the primary key. your course table would have a foriegn key for the relation. When I start thiking about this, I look at all the tables involved. Then I find which attributes the query it looking for. Then I begin to see where the join will be and any mathematical operations that may be in the query.

    If you have been studying for 6 months then you probably know that much so I don;t know if this helps. If you can provide a schema, maybe we can help you write some queries that are syntactically correct. Good luck.
    There is no place like 127.0.0.1 BUT 209.62.5.3 is my 127.0.0.1 away from 127.0.0.1!
  • Options
    TechJunkyTechJunky Member Posts: 881
    so use a select statement..

    select surname, fornames, course time attended
    with a where clause of the time where no other students were attending.

    This is really simple.

    Is this one table with many columns?

    multiple tables with multiple columns?

    I cant believe college questions are so easy :P

    To help disect these questions you need to do the following...

    decide what they want you to display, and then use the where clause to help you be more specific about the scenario.
  • Options
    nelnel Member Posts: 2,859 ■□□□□□□□□□
    hi fella's

    i dont want the answers to my q's because i feel i wouldnt be learning anything through that. i just want some guidance on how to look at the schema and see how to find the attributes i need to answer the question.

    its not just a simple select something from table 1, its looking at using multiple joins and subqueries aswell?

    i just can seem to see which attributes i need to use to find the correct answer, i always seem a mile off!

    ooo and btw ...ive been doing it 6 weeks - not 6 months lol
    Xbox Live: Bring It On

    Bsc (hons) Network Computing - 1st Class
    WIP: Msc advanced networking
  • Options
    NetstudentNetstudent Member Posts: 1,693 ■■■□□□□□□□
    ohhh...my fault, wasn't wearing my reading glasses... icon_rolleyes.gif
    There is no place like 127.0.0.1 BUT 209.62.5.3 is my 127.0.0.1 away from 127.0.0.1!
  • Options
    TechJunkyTechJunky Member Posts: 881
    well from that question it sounds like you need to use an inner join because you are needing to pull the same data from multiple tables.

    Database structure would defiantly help.
  • Options
    nelnel Member Posts: 2,859 ■□□□□□□□□□
    ok then, so how do you know what type of join to use?
    Xbox Live: Bring It On

    Bsc (hons) Network Computing - 1st Class
    WIP: Msc advanced networking
  • Options
    nelnel Member Posts: 2,859 ■□□□□□□□□□
    so how would i put this in a query...

    i have basically created a query to find which employee's have been on a course that employee x hasnt. ive done that ok but is there a basic syntax that will allow me to elimanate anyone from the output which has been on a course employee x has?
    Xbox Live: Bring It On

    Bsc (hons) Network Computing - 1st Class
    WIP: Msc advanced networking
Sign In or Register to comment.