Skip to main content
0 online
theremin Mar 19, 2004

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....

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.

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.