Join TSR now and get all your revision questions answeredSign up now
    Offline

    10
    ReputationRep:
    (Original post by I_Am_The_Man)
    Hello could someone clarify this for me:

    When using a SELECT statement to query a database I often get confused with what to put in the FROM statement. If you were selecting attributes x,y,z would you input all tables in the FROM statement that contain the attributes in x,y,z? Or does it depend more on the context?

    Thanks for your help! (You can see I didn't do a database project!)
    http://sqlzoo.net/wiki/SELECT_from_BBC_Tutorial

    Check ^ out
    Offline

    14
    ReputationRep:
    I really wish they'd kept comp3 as two separate exams, as it is it's like a towering pile of suck.
    Far too much content to be able to recall all in one go.
    Offline

    10
    ReputationRep:
    (Original post by I_Am_The_Man)
    Ok thanks yes I think you choose tables that you reference even in the WHERE statement. So I'm going to fill the FROM statement in last.
    FROM statements go after SELECT and before WHERE e.g

    SELECT students FROM tblStudents WHERE NoOfGCSEs = 8

    Would select all the student names from a table of students who have 8 GCSE's
    Offline

    0
    ReputationRep:
    (Original post by danielnkwocha)
    FROM statements go after SELECT and before WHERE e.g

    SELECT students FROM tblStudents WHERE NoOfGCSEs = 8

    Would select all the student names from a table of students who have 8 GCSE's
    I know that, but what I mean is the exam I will fill in the FROM statement part of the query last.
    Offline

    1
    ReputationRep:
    (Original post by I_Am_The_Man)
    I know that, but what I mean is the exam I will fill in the FROM statement part of the query last.
    I'm not sure what you mean. The syntax is SELECT FROM WHERE. The mark scheme's sometimes have 2 options, one using inner join and one without. Don't worry about it if you don't get the inner join bit, I don't! XD
    Offline

    0
    ReputationRep:
    While there is a lot of stuff to understand, there is a **** tonne of memorisation for this exam ... especially with those definitions and how damn specific the mark schemes are
    Offline

    2
    ReputationRep:
    Ugh this can go either really well or really badly T_T
    Offline

    0
    ReputationRep:
    Apologies about my stupidity yet again, but i'm unsure about yet another recursion-trace-table-fill-in question - (2012, Q10(e)) The thing is, when compared to the mark scheme, i get the Discovered array boxes correct from [1] to [6], but i don't understand how the code actually reaches Discovered[7]? and furthermore, the CompletelyExplored array is currently completely blank.. could someone help me out? Recursion seriously is not my strong point.. Are there any resources that I can read about recursive techniques because it honestly messes me up every time
    Offline

    0
    ReputationRep:
    (Original post by moogoomonkey)
    I'm not sure what you mean. The syntax is SELECT FROM WHERE. The mark scheme's sometimes have 2 options, one using inner join and one without. Don't worry about it if you don't get the inner join bit, I don't! XD
    I don't either! But what I mean is I will put the statements in the order SELECT FROM WHERE. However, I am going to consider the FROM statement last after considering what data is selected and conditions that I place in the WHERE statement. I know I made it sound a bit ambiguous.
    Offline

    0
    ReputationRep:
    On the specimen paper mark scheme, on Question 4D, is the WHERE statement right?!?! No mention of the name "Bloggs" at all!? Anyone understand what's going on there?? :confused:
    Offline

    2
    ReputationRep:
    (Original post by A Wise Ninja)
    On the specimen paper mark scheme, on Question 4D, is the WHERE statement right?!?! No mention of the name "Bloggs" at all!? Anyone understand what's going on there?? :confused:
    Yeah, it's a mistake in the mark scheme, I'd write it as:

    SELECT Type, Year, Condition, PricePaid
    FROM Coin, Supplier
    WHERE Coin.SupplierID = Supplier.SupplierID
    AND Supplier.SupplierName = "Bloggs"
    ORDER BY PricePaid ASC
    Offline

    14
    ReputationRep:
    93% UMS in this exam for the A* is looking more and more unlikely by the second.
    Offline

    0
    ReputationRep:
    (Original post by Sketch)
    Apologies about my stupidity yet again, but i'm unsure about yet another recursion-trace-table-fill-in question - (2012, Q10(e)) The thing is, when compared to the mark scheme, i get the Discovered array boxes correct from [1] to [6], but i don't understand how the code actually reaches Discovered[7]? and furthermore, the CompletelyExplored array is currently completely blank.. could someone help me out? Recursion seriously is not my strong point.. Are there any resources that I can read about recursive techniques because it honestly messes me up every time
    When DFS(7,7) is called the code:

    Discovered[V] ← True

    Sets the index 7 of discovered to true

    The vertex has no child vertices. So the loop:

    For each vertex U which is connected to V Do
    If Discovered[U] = False Then DFS(U, EndV)
    EndFor


    Does not execute and leads directly to:

    CompletelyExplored[V] ← True

    Thus setting the index in that array to true then the function ends, going back to where the function call DFS(5,7) left off.

    Now about trying to understand recursion. This what I think about when I doing something like this:

    > When a function is called within a function consider the newly called function, remembering where the last one left off (remember how stacks are used in recursion).

    > When a function ends go to where the previous function left off that called the function that just ended.

    It's just a process of working through it slowly and methodically, don't try to interpret what you think the algorithm does just follow it step by step. Maybe look for some worked examples of traces of a recursive function online for example, have a look at the binary tree traversal algorithms and run this applet (http://nova.umuc.edu/~jarc/idsv/lesson1.html), following the code and the applets animation of each traversal. Just an idea, I hoped I helped.
    Offline

    0
    ReputationRep:
    (Original post by Damask-)
    93% UMS in this exam for the A* is looking more and more unlikely by the second.
    I need 105 myself. I did the june paper and got 106 which is really cutting it close. God I am so nervous.
    Offline

    0
    ReputationRep:
    (Original post by D-Box)
    Yeah, it's a mistake in the mark scheme, I'd write it as:

    SELECT Type, Year, Condition, PricePaid
    FROM Coin, Supplier
    WHERE Coin.SupplierID = Supplier.SupplierID
    AND Supplier.SupplierName = "Bloggs"
    ORDER BY PricePaid ASC
    Ahh briliant, just what I put!
    Offline

    0
    ReputationRep:
    when querying with SQL for example:

    SELECT CustomerID FROM tblCustomer WHERE ...

    if I want to return the name 'Bob' would I have to put:

    WHERE tblCustomer.CustomerName = 'Bob'

    or can I put

    WHERE CustomerName = 'Bob'

    thanks
    Offline

    2
    ReputationRep:
    (Original post by ITomI)
    when querying with SQL for example:

    SELECT CustomerID FROM tblCustomer WHERE ...

    if I want to return the name 'Bob' would I have to put:

    WHERE tblCustomer.CustomerName = 'Bob'

    or can I put

    WHERE CustomerName = 'Bob'

    thanks
    if you're only querying one table then you won't need the table name prefix. However, if you include multiple tables in your query then yes you will need the <table name>. prefix
    Offline

    0
    ReputationRep:
    (Original post by I_Am_The_Man)
    When DFS(7,7) is called the code:

    Discovered[V] ← True

    Sets the index 7 of discovered to true

    The vertex has no child vertices. So the loop:

    For each vertex U which is connected to V Do
    If Discovered[U] = False Then DFS(U, EndV)
    EndFor


    Does not execute and leads directly to:

    CompletelyExplored[V] ← True

    Thus setting the index in that array to true then the function ends, going back to where the function call DFS(5,7) left off.

    Now about trying to understand recursion. This what I think about when I doing something like this:

    > When a function is called within a function consider the newly called function, remembering where the last one left off (remember how stacks are used in recursion).

    > When a function ends go to where the previous function left off that called the function that just ended.

    It's just a process of working through it slowly and methodically, don't try to interpret what you think the algorithm does just follow it step by step. Maybe look for some worked examples of traces of a recursive function online for example, have a look at the binary tree traversal algorithms and run this applet (http://nova.umuc.edu/~jarc/idsv/lesson1.html), following the code and the applets animation of each traversal. Just an idea, I hoped I helped.
    Thanks so much for that and yeah I think the "unwinding" notion of recursion is starting to grow on me.. but it's just writing out trace tables for recursive procedures that I find hard, i.e. what actually is it that is needed to be written in the boxes.. I think it would be easier to visualise on a stack to make things clearer
    Offline

    0
    ReputationRep:
    (Original post by pixelfrag)
    if you're only querying one table then you won't need the table name prefix. However, if you include multiple tables in your query then yes you will need the <table name>. prefix
    thank you
    Offline

    0
    ReputationRep:
    (Original post by pixelfrag)
    if you're only querying one table then you won't need the table name prefix. However, if you include multiple tables in your query then yes you will need the <table name>. prefix
    That is true however it appears according to this:

    SELECT EmailAddress, Forename, Surname
    FROM Book, Member, Loan
    WHERE Author = „Lucas Bailey‟ AND
    Book.BookID=Loan.BookID AND
    Member.MemberID=Loan.MemberID


    Where:

    Book(BookID, Title, Author, Publisher)
    Member(MemberID, Surname, Forename, HouseNumber, StreetName,
    Town, County, Postcode, DateOfBirth, EmailAddress)
    Loan(MemberID, BookID, LoanDate, DueBackDate, Returned)


    It appears that if the attribute only appears in one relation you don't have to reference the table name. Correct me if I am wrong.
 
 
 
If you won £30,000, which of these would you spend it on?

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Quick reply
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.