Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

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 Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old April 18th, 2008, 04:58 AM
awyeah awyeah is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 15 awyeah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 31 m 34 sec
Reputation Power: 0
SQL query on multiple tables

Hello,

I am currently a newbie to VB 6.0. I am trying to do a SQL select query on two different tables in a single access database (.mdb) file I have. This is what I have:

Table 1 name: Jan2006
---------------------------------------------------------
StnCode CustomerNo Name1 Name2
0121 00200001 HARWANT REALTY SDN BHD
0121 00200003 EUROPE KITCHEN STATION
0121 00200004 COLISEUM CAFE & HOTEL
0121 00200005 SKT V K KALYANASUNDRAM
0121 00200007 F T LAND CARS SDN BHD
0121 00200008 CYCLE & CARRIAGE BINTANG
0121 00200010 YAYASAN UBAIDI


Table 2 name: 24Months
---------------------------------------------
CustomerNo
00200002
00200003
00200004
00200005
00200006
00200008
00200011


My aim is to use the CustomerNos in Table: 24Months and extract the whole row (data) in Table1 corresponding only to that particular customer no. I am trying to use SQL query, here is what I have. I am trying to use inner join,
however have not yet achieved my desired output. Can anyone help me with this? All help is appreciated.

Code:
sql6(lngPosition6) = "SELECT Jan2006.CustomerNo, Jan2006.Name1, Jan2006.Name2, " _
 & "24Months.CustomerNo FROM Jan2006 INNER JOIN 24Months ON Jan2006 " _
 & "Jan2006.CustomerNo = 24Months.CustomerNo"

Reply With Quote
  #2  
Old April 18th, 2008, 12:10 PM
medialint's Avatar
medialint medialint is offline
spirit duplicator
Click here for more information.
 
Join Date: Apr 2004
Location: \\Firecrate\
Posts: 12,195 medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)  Folding Points: 230955 Folding Title: Super Ultimate Folder - Level 1Folding Points: 230955 Folding Title: Super Ultimate Folder - Level 1Folding Points: 230955 Folding Title: Super Ultimate Folder - Level 1Folding Points: 230955 Folding Title: Super Ultimate Folder - Level 1Folding Points: 230955 Folding Title: Super Ultimate Folder - Level 1Folding Points: 230955 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Months 2 Weeks 5 Days 10 h 34 m 36 sec
Reputation Power: 2500
You look pretty close try this..

Code:
SELECT Jan2006.CustomerNo, Jan2006.Name1, Jan2006.Name2
FROM Jan2006 INNER JOIN 24Months 
ON Jan2006.CustomerNo = [24Months].CustomerNo;
__________________
medialint.com

"Energy has the opportunity to change the climate if it's done right." - Sen. John Ensign, R-Nev. (quoted out of context)

Reply With Quote
  #3  
Old April 19th, 2008, 04:04 AM
awyeah awyeah is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 15 awyeah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 31 m 34 sec
Reputation Power: 0
Thanks, works like a charm Still reading about SQL select.. didn't know the square brackets were so effective in this case.

regards,
JD

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > SQL query on multiple tables


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 5 hosted by Hostway