Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2008
    Posts
    16

    Unanswered: Select statement

    I am trying to do a select statement, but its a bit different from what i am used to. It only involves 1 table (tblBook) which is
    BookTitle
    isbn
    btName
    datePublished
    pubId
    ageLower
    ageUpper
    value

    I need to Give the titles of books (btName) which have the same value as ‘Harry Potter’. Do not include Harry Potter in your output.

    I am trying somthing like
    Code:
    Select * From tblBook.value Where tblBook.btName = 'Harry Potter'
    I have no idea if i am on the right lines and also i am not sure how to then afterwards omit the value for Harry Potter. Any help would be great,
    cheers

  2. #2
    Join Date
    Mar 2007
    Posts
    623
    i am not sure how to then afterwards omit the value for Harry Potter.
    Do not include the BTNAME column (* picks all columns) in the SELECT list - specify the column names you want to output (BOOKTITLE only?).

    I am afraid, that during translation from the original language, this homework assignment changed its meaning, so it is hard to tell what you are supposed to do.

    By the way, you can SELECT from tables, not columns (tblBook.value is column). Have a look at SELECT statement syntax and semantics.

    [Edit: added last paragraph]

  3. #3
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    I might be wrong, but this is how I understood the problem:
    Code:
    select b.btname
    from tblbook b
    where b.value = (select b1.value          --> this is how much "Harry Potter" costs
                     from tblbook b1
                     where b1.btname = 'Harry Potter'
                    )
      and b.btname <> 'Harry Potter';         --> but don't display the "Harry Potter" book itself

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    nice one, littlefoot

    but please remember, you should not just hand students their homework answers
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •