General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old May 15th, 2004, 01:15 PM
photoshop_god photoshop_god is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 photoshop_god User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Simple sql statement problem

Hi,

I'm new to this forum and am hoping that someone can help.

My app is an asp application running on an ms access database.

I have two tables , customers and couplesInfo

I have a main page for displaying customer info. I have an if then statement that will display a link if the client has filled out the couples form. The two fields that have the same information are custID and cicustID. I need the main page to display info regardless if a client has filled out the couples form. For the link to display the couples info I need to get the ciID from the couples form that matches that particular client in the main page. The sql statement I'm having trouble with is this one. tkey is the id that is passed from the customer selection page. I have stripped down this statement in hopes that this will make it easier for someone to help.

strsql = "SELECT * FROM tblCustomers, tblCouplesInfo WHERE custID = " & tkey

I'm still learning sql and would appreciate any help. I have tried several different ways and none of them have worked.

Reply With Quote
  #2  
Old May 16th, 2004, 11:18 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
You can do this all in one statement, using a join.
Code:
SELECT * FROM customers cu LEFT JOIN couples co ON cu.id = co.id
Replace the id with whatever your primary key fields are. This will return all records for both tables that are joined by the key. If the couples table has not been completed, the results for the couples fields will be NULL.
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > Simple sql statement problem


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


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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway