Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > MySQL > newbie to mysql stuck with a command

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-30-03, 11:24
Derrick Derrick is offline
Registered User
 
Join Date: Nov 2003
Posts: 6
newbie to mysql stuck with a command

I am trying to self teach mysql to myself through a tutorial and I am stuck with a command.

i have this table:

+------------+------------+--------+-------+
| PROJECT_ID | CONSULTANT | DATE | HOURS |
+------------+------------+--------+-------+
| P01 | SUE | 910626 | 5.0 |
| P01 | SUE | 910628 | 3.0 |
| P03 | TED | 910713 | 6.0 |
| P01 | URI | 910630 | 4.0 |
| P03 | TED | 910715 | 7.0 |
| P05 | TED | 910622 | 1.0 |
| P03 | RAY | 910715 | 4.0 |
| P05 | TED | 910624 | 3.0 |
+------------+------------+--------+-------+

I am trying to display all the entries in the table except for those by consultant SUE.

I thought it might be something like:

SELECT * FROM consultants WHERE CONSULTANT not like SUE;

but it isnt working.

Thanks for reading this,
Derrick
Reply With Quote
  #2 (permalink)  
Old 11-30-03, 12:34
ika ika is offline
Registered User
 
Join Date: Oct 2003
Location: Slovakia
Posts: 482
Re: newbie to mysql stuck with a command

Quote:
Originally posted by Derrick
I am trying to self teach mysql to myself through a tutorial and I am stuck with a command.

i have this table:

+------------+------------+--------+-------+
| PROJECT_ID | CONSULTANT | DATE | HOURS |
+------------+------------+--------+-------+
| P01 | SUE | 910626 | 5.0 |
| P01 | SUE | 910628 | 3.0 |
| P03 | TED | 910713 | 6.0 |
| P01 | URI | 910630 | 4.0 |
| P03 | TED | 910715 | 7.0 |
| P05 | TED | 910622 | 1.0 |
| P03 | RAY | 910715 | 4.0 |
| P05 | TED | 910624 | 3.0 |
+------------+------------+--------+-------+

I am trying to display all the entries in the table except for those by consultant SUE.

I thought it might be something like:

SELECT * FROM consultants WHERE CONSULTANT not like SUE;

but it isnt working.

Thanks for reading this,
Derrick


SELECT * FROM consultants WHERE CONSULTANT <> 'SUE';
(this is better)

SELECT * FROM consultants WHERE CONSULTANT not like 'SUE';
Reply With Quote
  #3 (permalink)  
Old 11-30-03, 13:58
Derrick Derrick is offline
Registered User
 
Join Date: Nov 2003
Posts: 6
Thank you for your help, this stuff does not look that hard, but at times i have trouble figuring certain things out.

Derrick
Reply With Quote
  #4 (permalink)  
Old 11-30-03, 22:13
Derrick Derrick is offline
Registered User
 
Join Date: Nov 2003
Posts: 6
Im stuck on another section

Im trying to find the consultant_name and skill_id for all consultants with more than 7 hours for any given project.

this is what i thought it was(clearly you can see i am really mized up here)

SELECT consultant_name, skill_id
FROM consultants
WHERE HOURS IN
(SELECT HOURS
FROM time
GROUP BY CONSULTANT
WHERE SUM(HOURS) > '7');

Please give me some advice

Thanks,
Derrick

Consultants:
+------------+-----------------+----------+--------+
| CONSULTANT | CONSULTANT_NAME | SKILL_ID | REGION |
+------------+-----------------+----------+--------+
| RAY | Smith | PR | W |
| SUE | Jones | AN | NE |
| TED | Doe | DD | NE |
| URI | Roe | CP | S |
+------------+-----------------+----------+--------+

Time:
+------------+------------+--------+-------+
| PROJECT_ID | CONSULTANT | DATE | HOURS |
+------------+------------+--------+-------+
| P01 | SUE | 910626 | 5.0 |
| P01 | SUE | 910628 | 3.0 |
| P03 | TED | 910713 | 6.0 |
| P01 | URI | 910630 | 4.0 |
| P03 | TED | 910715 | 7.0 |
| P05 | TED | 910622 | 1.0 |
| P03 | RAY | 910715 | 4.0 |
| P05 | TED | 910624 | 3.0 |
+------------+------------+--------+-------+
Reply With Quote
  #5 (permalink)  
Old 11-30-03, 22:29
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,556
Code:
select C.consultant_name , C.skill_id , T.project_id , sum(T.hours) from consultants C inner join `time` T on C.consultant = T.consultant group by C.consultant_name , C.skill_id , T.project_id having sum(T.hours) > 7
rudy
http://r937.com/
Reply With Quote
  #6 (permalink)  
Old 11-30-03, 22:59
Derrick Derrick is offline
Registered User
 
Join Date: Nov 2003
Posts: 6
im a little confused on this section here, could someone explain it to me?

from consultants C
inner
join `time` T
on C.consultant = T.consultant

thanks,
Derrick
Reply With Quote
  #7 (permalink)  
Old 12-01-03, 00:09
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,556
um, that's an inner join

try one of these tutorials --

Getting the Right Data with SQL Joins
ANSI Joins
SQL Join

rudy
Reply With Quote
  #8 (permalink)  
Old 12-01-03, 00:17
Derrick Derrick is offline
Registered User
 
Join Date: Nov 2003
Posts: 6
thanks
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On