join in select statement

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jul 2007
Posts: 189
Reputation: plusplus is an unknown quantity at this point 
Solved Threads: 16
plusplus plusplus is offline Offline
Junior Poster

join in select statement

 
0
  #1
Oct 14th, 2007
I have the following select statement which works, I need help to adapt it

adobau.RecordSource = "SELECT * FROM Liegenschaften INNER JOIN tblbau ON Liegenschaften.Rimo_Liegnr = tblbau.Liegenschaft"

my adobau.recordset loops through Liegenschaften and gives me all the info of Liegenschaften that has match in tblbau, but I want some info from tblbau also, how would I do this?
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,099
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 128
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: join in select statement

 
0
  #2
Oct 14th, 2007
there is no problem with the query . You might need to change the join condition . Kindly post both of your tables structure for more details.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 189
Reputation: plusplus is an unknown quantity at this point 
Solved Threads: 16
plusplus plusplus is offline Offline
Junior Poster

Re: join in select statement

 
0
  #3
Oct 14th, 2007
tbl 1 has fields id, name,address
tbl2 has fields id, date
tbl2.id refers to same id of tbl1
I want all records from tbl2 print the name address and date.
name and address are in tbl1 and date in tbl2
Can this be done in one select statement?
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 30
Reputation: yello is an unknown quantity at this point 
Solved Threads: 4
yello yello is offline Offline
Light Poster

Re: join in select statement

 
0
  #4
Oct 14th, 2007
Try this query.

adobau.RecordSource = "SELECT Liegenschaften.name,Liegenschaften.address,tblbau.date FROM Liegenschaften INNER JOIN tblbau ON Liegenschaften.Rimo_Liegnr = tblbau.Liegenschaft"
Last edited by yello; Oct 14th, 2007 at 8:38 pm.
www.easyprograming.com
Make Your Programing Easy
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 189
Reputation: plusplus is an unknown quantity at this point 
Solved Threads: 16
plusplus plusplus is offline Offline
Junior Poster

Re: join in select statement

 
0
  #5
Oct 15th, 2007
My problem is not the recordsource, it gives me all the records I need.
My problem is the recordset, it points only to one table and I need info from secondtable also
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 56
Reputation: culebrin is an unknown quantity at this point 
Solved Threads: 1
culebrin culebrin is offline Offline
Junior Poster in Training

Re: join in select statement

 
0
  #6
Oct 15th, 2007
I think you should give a try the yello's suggestion, and to call certain column use: adobau("columnname"), columnname could be any of the columns used in the query, not exclusively of a certain table, the recordset does not know anything about the tables used in your query, it only can see the columns used in the query, all of them:

p.e:
adobau.RecordSource = "SELECT Liegenschaften.name,Liegenschaften.address,tblbau.date FROM Liegenschaften INNER JOIN tblbau ON Liegenschaften.Rimo_Liegnr = tblbau.Liegenschaft"

and the call:

textbox1.text = adobau("name")
textbox2.text = adobau("address")
textbox3.text = adobau("date")

and so on no matter which table you used in the query. That's why you should name with different names, similar columns in both tables.

Cheers,

Omar
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 189
Reputation: plusplus is an unknown quantity at this point 
Solved Threads: 16
plusplus plusplus is offline Offline
Junior Poster

Re: join in select statement

 
0
  #7
Oct 15th, 2007
ok, I guess that was my problem, I have in both tables a column with same name and when I try to get that one it gives me an error. I thought it's because the recordset doesn't point to that table, now I see that it's because it doesn't know which column, which table.
I can't change the names of the columns, because I'm using an existing database that's being used for hundreds of programs already. I got it to work with two ados and two select statement, but I'd still like to do it in one. Do you have any suggestions?
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 30
Reputation: yello is an unknown quantity at this point 
Solved Threads: 4
yello yello is offline Offline
Light Poster

Re: join in select statement

 
0
  #8
Oct 15th, 2007
If you have same column name in two tables you must refer the column by [Table Name].[Column Name]
www.easyprograming.com
Make Your Programing Easy
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 189
Reputation: plusplus is an unknown quantity at this point 
Solved Threads: 16
plusplus plusplus is offline Offline
Junior Poster

Re: join in select statement

 
0
  #9
Oct 16th, 2007
It works thank you all for your help
this was the syntax that worked
ado1.recordset ("tblname.columnname")
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC