PDA

View Full Version : Sql Help! Pls Help Me With These!



cpt_azad
05-06-2004, 02:38 AM
k, i had a huge sheet to complete (more like 5 sheets) on SQL, and i'm stuck on these last ones that i don't understand, so anyone that knows SQL please help me!!!!!!!! pwetty pwease!!:





1) Name the required parts for any SELECT statement.
2) In the WHERE clause, are single quotation marks required for all the data?
3) Under what part of the SQL Language does the SELECT statment (database query) fall?
4) Can multiple conditions be used in the WHERE clause?


Look over the following SELECT statements.  Determine whether the syntax is correct.  If the syntax is incorrect, what would correct it? A table called employee_tbl is used here:

a.  SELECT employee_id, last_name, first_name,
    FROM EMPLOYEE_TBL;

b.  SELECT EMPLOYEE_ID, LAST_NAME
    ORDER BY EMPLOYEE_TBL
    FROM EMPLOYEE_TBL;

c.  SELECT EMPLOYEE_ID, LAST_NAME, FIRST_NAME
    FROM EMPLOYEE_TBL
    WHERE EMPLOYEE_ID = '333333333'
    ORDER BY EMPLOYEE_ID;

d.  SELECT EMPLOYEE_ID, LAST_NAME, FIRST_NAME
    FROM EMPLOYEE_TBL
    WHERE EMPLOYEE_ID = '333333333'
    ORDER BY 3, 1, 2;

cpt_azad
05-06-2004, 02:55 AM
bUmP??? please guys, it's due tomorrow and i still have to study like hell for 4 exams (also tomorrow :angry: )

toco004
05-06-2004, 04:06 AM
I seen this some where but i
don't remember how the fuck it was done.
if i come across it i'll post it ASP.

DrSpud
05-06-2004, 04:32 AM
Originally posted by cpt_azad@5 May 2004 - 22:46
1) Name the required parts for any SELECT statement.
2) In the WHERE clause, are single quotation marks required for all the data?
3) Under what part of the SQL Language does the SELECT statment (database query) fall?
4) Can multiple conditions be used in the WHERE clause?


Look over the following SELECT statements.  Determine whether the syntax is correct.  If the syntax is incorrect, what would correct it? A table called employee_tbl is used here:

a.  SELECT employee_id, last_name, first_name,
    FROM EMPLOYEE_TBL;

b.  SELECT EMPLOYEE_ID, LAST_NAME
    ORDER BY EMPLOYEE_TBL
    FROM EMPLOYEE_TBL;

c.  SELECT EMPLOYEE_ID, LAST_NAME, FIRST_NAME
    FROM EMPLOYEE_TBL
    WHERE EMPLOYEE_ID = '333333333'
    ORDER BY EMPLOYEE_ID;

d.  SELECT EMPLOYEE_ID, LAST_NAME, FIRST_NAME
    FROM EMPLOYEE_TBL
    WHERE EMPLOYEE_ID = '333333333'
    ORDER BY 3, 1, 2;
1) The table field(s) on the SELECT line and table name(s) on the FROM line.
2) No
3) Not sure ... Query? (Simple) Retrieval?
4) Yes

a.
SELECT employee_id, last_name, first_name,
to
SELECT employee_id, last_name, first_name

b.
ORDER BY EMPLOYEE_TBL
FROM EMPLOYEE_TBL;
to
FROM EMPLOYEE_TBL
ORDER BY EMPLOYEE_ID;

c. Correct

d.
ORDER BY 3, 1, 2;
to
ORDER BY FIRST_NAME, EMPLOYEE_ID, LAST_NAME;




I could be wrong, of course. But I'm fairly confident. You should definitely review the material you've been given to make sure these answers make sense in the context you're using them in.

cpt_azad
05-06-2004, 05:25 AM
wow thanks drspud, i reviewed the material and the answers you gave me fill in the blanks, but one thing i still don't understand is why 4) "Can multiple conditions be used in the WHERE clause?" is answered as yes, it seems to make sense, but i don't know why that is same as number 2).

but thank you very very very much drspud, ur a real lifesaver :) i owe u a cookie :) . now to go back and study some more :(

DrSpud
05-06-2004, 06:02 AM
Originally posted by cpt_azad@6 May 2004 - 01:33
one thing i still don't understand is why  4) "Can multiple conditions be used in the WHERE clause?" is answered as yes, it seems to make sense, but i don't know why that is same as number 2).
:huh: Not sure I understand what you're saying.
Single quotes (') are neccessary for everything except number, I believe. When they use
WHERE EMPLOYEE_ID = '333333333' the EMPLOYEE_ID field has been defined as a char, not a number. Otherwise
WHERE EMPLOYEE_ID = 333333333 would be used.

And for 4), this is a valid clause:

WHERE EMPLOYEE_ID = '333333333' OR EMPLOYEE_ID = '333333334'
Multiple conditions certainly can be used in the WHERE clause.

cpt_azad
05-06-2004, 06:55 AM
Originally posted by DrSpud+5 May 2004 - 22:10--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (DrSpud @ 5 May 2004 - 22:10)</td></tr><tr><td id='QUOTE'> <!--QuoteBegin-cpt_azad@6 May 2004 - 01:33
one thing i still don&#39;t understand is why 4) "Can multiple conditions be used in the WHERE clause?" is answered as yes, it seems to make sense, but i don&#39;t know why that is same as number 2).
:huh: Not sure I understand what you&#39;re saying.
Single quotes (&#39;) are neccessary for everything except number, I believe. When they use
WHERE EMPLOYEE_ID = &#39;333333333&#39; the EMPLOYEE_ID field has been defined as a char, not a number. Otherwise
WHERE EMPLOYEE_ID = 333333333 would be used.

And for 4), this is a valid clause:

WHERE EMPLOYEE_ID = &#39;333333333&#39; OR EMPLOYEE_ID = &#39;333333334&#39;
Multiple conditions certainly can be used in the WHERE clause. [/b][/quote]
it&#39;s starting to make sense now. you see, the book we&#39;re learning from is kind of messed up because it doesn&#39;t use mySQL (the one we&#39;re using) examples so therefore things like varchar are undefined (we have to use char) and number has to be replaced with decimal. i hate my info tech class because all we do is take notes notes and more notes (believe it or not we have only used the computers for work/play (play :D ) only 1 week out of the whole semester, the rest of the time all we did were notes. that&#39;s why i&#39;m so rusty at SQL because i don&#39;t have to much hands on experience. thanks again&#33;&#33;&#33;