|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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" |
|
#2
|
||||
|
||||
|
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) |
|
#3
|
|||
|
|||
|
Thanks, works like a charm
Still reading about SQL select.. didn't know the square brackets were so effective in this case.regards, JD |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > SQL query on multiple tables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|