Skip to main content
0 online
theremin thereminOG 2002

I did all the ones I could, but had trouble coming up with like the last 6 of the SQL statements required. So, I put what the database looks like, and the problems I couldn't figure out into Word. And, it can be viewed either in Word here, RTF here, or HTM here. A big thanks in advance to whoever winds up helping me, cuz this is really killing me right now. I only managed to do like 3 of the problems, which is bad.

yay yayOG 2004

These shouldn't be too bad... I don't think just posting answers is really going to help, anything/questions in particular you're having a problem with?

theremin thereminOG 2002

No, actually. haha These are my questions.

theremin thereminOG 2002

Maybe you can tell me this... Say I have my SQL statements typed out in something.sql. Did you ever work with mySQL Control Center? 'Cause instead of running sql file via command line, I wanna try to run it via GUI using mySQL Command Center this time. How would I do so. I already have mySQL Command Center on my computer, and I have it all configured for tunneling, since the remote server I'll be running it off of, required me to, an all. So, that's all take care of, but what's the next step? How would I run something.sql using the mySQL Command Center GUI?

iwz iwz

it's easy. since you're all setup already, just login, go to the database, and click on the SQL button on the toolbar.

then you can type in sql or open up a .sql file.

theremin thereminOG 2002

You have all the answers. Excellent. Thanks.

iwz iwz

Ok, well for #2 on that page..

you basically want to join the REP and CUSTOMER tables on the REP_NUM column, and also CUSTOMER.CREDIT_LIMIT = '$10,000.00'. Then just add in the DISTINCT keyword in the select statement to only retrieve each REP once.

theremin thereminOG 2002

Thank you Ian. Every bit helps.

theremin thereminOG 2002

So, it'd be...

SELECT DISTINCT(REP_NUM, LAST_NAME, FIRST_NAME)
FROM REP
WHERE REP.REP_NUM = CUSTOMER.REP_NUM
AND CUSTOMER.CREDIT_LIMIT = '$10,000'

?

iwz iwz

looks pretty good to me.

deanh77 deanh77Founder

or you could do an inner join.

iwz iwz

how would you write that?

deanh77 deanh77Founder

well.. a select with a WHERE clause that matches two columns from different tables IS an INNER JOIN (by definition).

you can use the following syntax if you like.

SELECT DISTINCT(REP_NUM, LAST_NAME, FIRST_NAME)
FROM REP INNER JOIN CUSTOMER
ON REP.REP_NUM = CUSTOMER.REP_NUM
WHERE CUSTOMER.CREDIT_LIMIT = '$10,000'

hehehe... just being difficult.

theremin thereminOG 2002

Good to know. Thanks. I haven't tried INNER JOINs yet, because I didn't understand them, but now I do, a little better.

deanh77 deanh77Founder

in case I wasn't clear enough:

SELECT col1, col2 FROM table1, table2 WHERE table1.col3 = table2.col9

is an inner join.

iwz iwz

question 3 is confusing, because it mentions parts are in "pairs", and I don't see how they are paired at all. I don't really understand the question. But, maybe what they're looking for is a GROUP BY on the CLASS column.

theremin thereminOG 2002

I think they use the word pair, because there's more than one item in each class. For example, there's not one, but 3 items in class HW (Iron, Cordless Drill, Stand Mixer)... and for some twisted reason, they call that a pair, I guess.

theremin thereminOG 2002

This is what I came up with and hopefully it's what's wanted...

SELECT PART_NUM, DESCRIPTION, CLASS
FROM PART
GROUP BY CLASS
ORDER BY CLASS;

iwz iwz

some of the things in there seem to require more than 1 query, such as the first one, and the last one.

what version of mysql are you doing this on? 4.1 supports subqueries, but 4.0 doesn't. do you have to answer each question with a single query?

theremin thereminOG 2002

Using subqueries is alright except in the case of the second problem where i wasn't supposed to use one, but we're already pass that now, so in the case of the remainder of the problems, yes, subqueries can be utilized. And, not using subqueries is fine too, if that's what you favor. Which ever way is good. If you see that using more that a single statement seems best over using a subquery or more is best, than go with that way. I'm unsure of which version this is, but subqueries are supported as well.

theremin thereminOG 2002

ok, Found out what version.

"Your MySQL connection id is ***** to server version: 4.1.1-alpha-log"

Welcome Back to eZabel

It's been a while. Here's what's new.

eZabel Lore

A complete history of our community — stats, Hall of Fame, legendary threads, and more.

View the Lore →

Everything Preserved

All 225,969 pieces of content from 2000–2014 are here — forums, messages, journals, photos, polls, and events.

💎

Gems

Spot something you love — a legendary comment, a classic thread, a great photo? Log in and click the diamond icon to mark it as a Gem. Add a note about why it's special. The best stuff surfaces on the Gems page.