SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 1st, 2003, 01:31 PM
guynorton guynorton is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 3 guynorton User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
trouble with query

I have a database (Access 2000) that holds ship itinerary information and a list of businesses at ports that are visited

I want to get a list businesses at the ports a ship visits over a period of time:

Eg. Find all businesses in the ports that the ‘Carnival Destiny’ visits over the next fortnight.

---------------------------------------------------------------------------------
TABLES:

ItMain:

CID ‘ primary key – Cruise ID
Ship ‘ name of ship

ItDates :

CID
Date ‘ dates an itinerary is repeated on e.g. 7-7-03, 7-14-03 etc

ItPorts:

CID
Day ‘ cruise day (seven day cruise 0-1-2-3-4-5-6)
Port ‘ port that ship visits


BizMain:

BID ‘ primary key - Business ID
Port ‘ port that business is located in

-----------------------------------------------------------------------------------

I thought this would be easy to solve, even with my poor knowledge of SQL.

Alas, No! My subquery refused to cooperate!

Can anyone post a solution for me, or even point me in the right direction (so that I can have the pleasure of solving it myself)

Thanks in advance,

Guy Norton

Reply With Quote
  #2  
Old October 2nd, 2003, 04:23 PM
dcarva's Avatar
dcarva dcarva is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 633 dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 18 m 20 sec
Reputation Power: 7
Join your tables with an INNER JOIN. Then use the WHERE clause to specify the date range.

Example:

SELECT i.CID, i.Ship
FROM itMain As i
INNER JOIN ItDates As d ON d.CID = i.CID
INNER JOIN ItPorts As p ON p.CID = i.CID
INNER JOIN BizMain As b on b.Port = p.Port
WHERE d.[Date] = '12/12/2001'

Hope this helps.

Reply With Quote
  #3  
Old October 2nd, 2003, 10:22 PM
guynorton guynorton is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 3 guynorton User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi Dcarva,
Thanks
It works under SQL server (added bid to it)
I'm trying to get it to work in Access but it's non-standard implementation of SQL doesnt want to know!

Thanks for the help
Cheers, Guy

P.S. I am only interested in getting the BID's. Is it possible to return them 'DISTINCT'...and stop my ASP script from looping and checking for dupes?

Reply With Quote
  #4  
Old October 3rd, 2003, 05:10 PM
dcarva's Avatar
dcarva dcarva is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 633 dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 18 m 20 sec
Reputation Power: 7
Yes. Distinct will return unique records.

---------
Hi Dcarva,
Thanks
It works under SQL server (added bid to it)
I'm trying to get it to work in Access but it's non-standard implementation of SQL doesnt want to know!

Thanks for the help
Cheers, Guy

P.S. I am only interested in getting the BID's. Is it possible to return them 'DISTINCT'...and stop my ASP script from looping and checking for dupes?

Reply With Quote
  #5  
Old October 4th, 2003, 09:00 AM
guynorton guynorton is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 3 guynorton User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
re DISTINCT
thanks!
(I say witha little embarrassment!)
Guy

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > trouble with query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT