Join 149,578 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,744 people online right now. Registration is fast and FREE... Join Now!
Based upon the contents of the PUBLISHER table, which of the following is not a valid SQL statement? 1) SELECT name, phone FROM publisher 2) SELECT name, contract FROM publisher 3) SELECT * FROM publisher; 4) SELECT Phone, Pubid FROM publisher;
Question 2
Which of the following queries will return all books that cost at least $25.00? 1) SELECT * FROM books WHERE cost > $25.00; 2) SELECT * FROM books WHERE cost >= 25.00; 3) SELECT * FROM books WHERE cost >= $25.00; 4) none of the above
Question 3
Which of the following select statements will change the column heading of the lname Last Name field? 1) SELECT * FROM lname 2) SELECT Last Name from lname 3) SELECT lname as [Last Name], fname FROM Names 4) SELECT Names From lname as [Last Name]
Thanks for all the help
James Bond C++ Spy
This post has been edited by James Bond C++ Spy: 16 Oct, 2007 - 01:52 PM
Hmmm, not sure if this was supposed to be part of another thread where all of the pertinent information is... but this just looks like you pasted your homework assignment.
As the rules state, we will not do your homework for you. If you need help with one specific problem and can tell us where you're hung up, we'd be happy to help.
No, these are part of a take home test that I can't seen to find the answers to anywhere in the book or on the net so I thought I would check here to see if someone could help.
Sorry, but we can't just do your homework for you.
What is the specific question you have... these are the most basic SQL statement there are so I'm not really sure what problem you're having. Are you confused by the question, do you not understand the wording.
Either way, you're going to have to tell us what exactly you don't understand before we can help. It's a site policy and is enforced quite strictly here.
QUOTE(James Bond C++ Spy @ 16 Oct, 2007 - 03:50 PM)
Question 1
Based upon the contents of the PUBLISHER table, which of the following is not a valid SQL statement? 1) SELECT name, phone FROM publisher 2) SELECT name, contract FROM publisher 3) SELECT * FROM publisher; 4) SELECT Phone, Pubid FROM publisher;
Depending on the contents of the publisher table any number of things could be wrong with the statement. In 1) check to see if name and phone are actually column names in the table, in 2) check to see if name and contract are valid column names... also check to see if the missing ; at the end is a typo on your part, if it's not, then 2) might not be valid, in 3) as long as the name of the table is in fact publisher, it should be fine, in 4) as long as Phone and Pubid are valid column names you should be fine.
QUOTE
Question 2
Which of the following queries will return all books that cost at least $25.00? 1) SELECT * FROM books WHERE cost > $25.00; 2) SELECT * FROM books WHERE cost >= 25.00; 3) SELECT * FROM books WHERE cost >= $25.00; 4) none of the above
Is cost a integer field or a float? If it's an integer, I don't think you can use decimal points in the where clause, the $ is almost definitely a no go, and the >= should be correct for "at least $25.00"
QUOTE
Question 3
Which of the following select statements will change the column heading of the lname Last Name field? 1) SELECT * FROM lname 2) SELECT Last Name from lname 3) SELECT lname as [Last Name], fname FROM Names 4) SELECT Names From lname as [Last Name]
Thanks for all the help
James Bond C++ Spy
Look up the correct syntax for "AS" which is how you change a column heading. Then, depending on the field names pick the correct one.
Thanks for the help question 1 I have no database to check so it's potluck here question 2 I didn't think you could use decimals but wasn't sure and didn't know if it was a integer field or a float. question 3 I thought AS was a keyword but there again I didn't have a database to check.
Anyway thanks for the help and just couldn't find the answers anywhere. But I was close 2 out of 3
If this is Microsoft SQL Server then the AS is correct and the ; will cause an error, so given that in question #1 3 and 4 aren't valid (unless the ; is a typo on your part). Question #2 query 2 will return the desired results, Question #3 Id have to say query 3 but in all my years of programming (MSSQL for 10 years now) I've never seen it done with [ ] before, and you cant use a ; in MSSQL last time I checked.
I have submitted the test and will post the correct answers to these questions as soon as I know. Thanks for all the help. I have a pretty good handle on this material but these questions confused me. (with no database query)
Thanks
James Bond C++ Spy
This post has been edited by James Bond C++ Spy: 16 Oct, 2007 - 02:45 PM
That must mean Microsoft SQL Server. Well, like I said before, Ive been using MSSQL for over 10 years now, way back when before they had a decent GUI to use, and Ive never seen a semi-colon at the end of a query (;), and Ive never seen an AS statement used that way. We've always done it like SELECT SomeColumn AS 'Your Column' FROM SomeTable so the [ ] is, well its new to me
Yes it is Microsoft. I had another question using the as and the [ ] is what confused me aswell. In the other question I used ' ' and it worked perfectly. Weird questions. Thanks so much for the replies and help.