How Do I Get The Queries To Bring Back the Exact Data I Need?

Author Message
DesignerMind

  • Total Posts : 1
  • Scores: 0
  • Reward points : 100
  • Joined: 6/11/2012
  • Status: offline
How Do I Get The Queries To Bring Back the Exact Data I Need? Monday, June 11, 2012 12:19 PM (permalink)
0
I have the following requirements for three queries I have to build, but the ones I've written bring back "too much data." The requirements are as follows:

Query 1 - Hispanic Customers 
Customer ID 
First Name 
Last Name 
Car Color

Query 2 - Customers who were born in March and own a pink Pontiac. 
Customer ID 
Last Name, First Name [Customer Name]

Query 3 - White Customers who own a Toshiba Laptop or an HP Laptop and a blue Buick. Customer ID 
Last Name, First Name [Customer Name] 
Computer
 
This is what I've written, which brings back to too data:
1)
SELECT DISTINCT CustomerID, firstname, lastname, Description
FROM customers, zlu_Race
WHERE zlu_race.description="Hispanic" Or zlu_race.RaceID=3;

2) 
SELECT customerid, (FirstName+'_'+LastName) AS [Customer Name], zlu_birthmonth.description
FROM Customers, zlu_BirthMonth
WHERE zlu_birthmonth.description="March";

3) Have no idea how to write it.

What am I doing wrong?  Can some help get these queries to bring back the correct records? I keep writing over and over, and it's driving me up the wall. Thanks a zillion!
 
Additionally:
NOTE: The main table = Customers, and it is normalized.
For lookup (zlu_) tables, I have:
zlu_BirthMonth
zlu_CarColor
zlu_Cars
zlu_Computers
zlu_Race
zlu_Residence
All zlu_ tables have an ID, Code, Description, ListOrder, and Active field.
 
 
#1
    gjones

    • Total Posts : 2291
    • Scores: 136
    • Reward points : 97970
    • Joined: 6/5/2001
    • Location: Ottawa, Ontario, Canada
    • Status: offline
    Re:How Do I Get The Queries To Bring Back the Exact Data I Need? Monday, July 02, 2012 10:09 PM (permalink)
    0
    Yes, I know this is an old post, I’m trying to clean up older posts that are unanswered.
    Did you ever figure this out? If so how?
     
    #2
      jandrew

      • Total Posts : 81
      • Scores: 0
      • Reward points : 15670
      • Joined: 11/27/2006
      • Status: offline
      Re:How Do I Get The Queries To Bring Back the Exact Data I Need? Wednesday, July 04, 2012 5:02 PM (permalink)
      0
      Is this still an issue? It is difficult to investigate this problem fully because there is too little information presented. We would most likely need the table definitions of all tables involved in your queries. Also, just to check are these queries being run against Microsoft SQL Servers? I only ask because how you are referencing some of the tables do not seem like the normal T-SQL syntax unless you are quoting the schema name in your queries as well, but that is unclear. Third, you do not clearly define what you mean by "too much data is returned". Are you getting duplicates? Is there data that is being returned in one of the queries that you do not think should match what you specified in your where clause? Specific examples would be needed in order to clearly identify where your query statement is going wrong.
      Joie
      "Since 1982"
       
      #3
        Online Bookmarks Sharing: Share/Bookmark

        Jump to:

        Current active users

        There are 0 members and 1 guests.

        Icon Legend and Permission

        • New Messages
        • No New Messages
        • Hot Topic w/ New Messages
        • Hot Topic w/o New Messages
        • Locked w/ New Messages
        • Locked w/o New Messages
        • Read Message
        • Post New Thread
        • Reply to message
        • Post New Poll
        • Submit Vote
        • Post reward post
        • Delete my own posts
        • Delete my own threads
        • Rate post

        2000-2013 ASPPlayground.NET Forum Version 3.9