Hello There, Guest!
View New Posts  |  View Today's Posts
SQL Programming?

  • 0 Vote(s) - 0 Average


02-19-2015, 08:36 PM #1
william7
Member
**
Posts: 205 Threads:49 Joined: Feb 2012 Reputation: 0

SQL Programming?
Can anyone give me some helpful advice in regards to this SQL programming problem in the screenshot below? I tried this and a UNION operator to no avail. I'm suppose to list the order number and order date for each order that either was placed by Johnson's Department Store or that contains an orderline for a Gas Range. There are orders for a Gas Range and Johnson's Department Store has made orders so there is data to this effect.


02-19-2015, 08:58 PM #2
KoBE
¯\_(ツ)_/¯
******
Global Moderators
Posts: 4,862 Threads:494 Joined: Jun 2011 Reputation: 67

RE: SQL Programming?

02-20-2015, 04:56 AM #3
william7
Member
**
Posts: 205 Threads:49 Joined: Feb 2012 Reputation: 0

RE: SQL Programming?
This is how it played me even though I clearly have a table ORDERS.


02-21-2015, 10:57 PM #4
KoBE
¯\_(ツ)_/¯
******
Global Moderators
Posts: 4,862 Threads:494 Joined: Jun 2011 Reputation: 67

RE: SQL Programming?

02-22-2015, 09:43 AM #5
william7
Member
**
Posts: 205 Threads:49 Joined: Feb 2012 Reputation: 0

RE: SQL Programming?
I goofed up KoBe. I should've been using the school's SQL Server database set up for this class through VMware Horizon Client as they told me to do. I used my SQL Server I set up on my computer with the same school materials. I find it easier to use than the school's which is slow and hangs up. So I redid what you first suggested on the school's computer with the OR operator and below is what I got, but it doesn't seem to match the data which I've included below. Look it all the duplicates! Where did all this come from?











I screwed up again! Below is what came out after I joined the two tables. Less duplicates, but it still seems wrong. What do you think?

This post was last modified: 02-22-2015, 09:58 AM by william7.

02-25-2015, 02:28 AM #6
KoBE
¯\_(ツ)_/¯
******
Global Moderators
Posts: 4,862 Threads:494 Joined: Jun 2011 Reputation: 67

RE: SQL Programming?
It's pulling multiple because it's pulling the row from both tables. Try doing a JOIN instead. This will pull the field in as a COLUMN instead of bring back the entire row from the ORDER_LINE table.

This code might work, I don't have your tables to test with:
Code:
SELECT O.ORDER_NUM, OL.ORDER_DATE
FROM ORDERS O
INNER JOIN ORDER_LINE OL ON O.ORDER_NUM = OL.ORDER_NUM
WHERE O.PART_NUM = 'DR93' OR OL.CUSTOMER_NUM = '608';
This post was last modified: 02-25-2015, 02:29 AM by KoBE.

02-25-2015, 03:55 AM #7
Lee Stevens
Senior Member
***
Posts: 345 Threads:54 Joined: Feb 2012 Reputation: 12

RE: SQL Programming?
william7, can i recommend you read through http://www.w3schools.com/sql/ you can choose the function from the left and it will give you examples how and when to use them.

02-25-2015, 08:39 PM #8
william7
Member
**
Posts: 205 Threads:49 Joined: Feb 2012 Reputation: 0

RE: SQL Programming?
Thanks KoBE! After some modification, I got it!

I'll check that out Lee. Thanks.
This post was last modified: 02-25-2015, 08:41 PM by william7.




Forum Jump:


Possibly Related Threads...
Thread Author Replies Views Last Post
  Programming Music AceInfinity 5 1,713 10-27-2015, 05:28 PM
Last Post: Sam Baker
  Go programming language KoBE 0 853 06-25-2015, 09:13 AM
Last Post: KoBE
   Quick Programming Challenge! AceInfinity 16 7,442 08-04-2014, 10:57 PM
Last Post: AceInfinity
  Free (legal) Windows phone programming ebooks Shintaro 2 1,659 06-06-2014, 04:50 PM
Last Post: Shintaro
  Factor Programming AceInfinity 0 1,441 04-06-2014, 12:54 AM
Last Post: AceInfinity


Users browsing this thread: 1 Guest(s)