944,038 Members | Top Members by Rank

Ad:
Oct 14th, 2007
0

join in select statement

Expand Post »
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?
Similar Threads
Reputation Points: 10
Solved Threads: 16
Posting Whiz in Training
plusplus is offline Offline
207 posts
since Jul 2007
Oct 14th, 2007
0

Re: join in select statement

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.
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007
Oct 14th, 2007
0

Re: join in select statement

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?
Reputation Points: 10
Solved Threads: 16
Posting Whiz in Training
plusplus is offline Offline
207 posts
since Jul 2007
Oct 14th, 2007
0

Re: join in select statement

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.
Reputation Points: 13
Solved Threads: 4
Light Poster
yello is offline Offline
30 posts
since Nov 2006
Oct 15th, 2007
0

Re: join in select statement

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
Reputation Points: 10
Solved Threads: 16
Posting Whiz in Training
plusplus is offline Offline
207 posts
since Jul 2007
Oct 15th, 2007
0

Re: join in select statement

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
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
culebrin is offline Offline
62 posts
since Aug 2007
Oct 15th, 2007
0

Re: join in select statement

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?
Reputation Points: 10
Solved Threads: 16
Posting Whiz in Training
plusplus is offline Offline
207 posts
since Jul 2007
Oct 15th, 2007
0

Re: join in select statement

If you have same column name in two tables you must refer the column by [Table Name].[Column Name]
Reputation Points: 13
Solved Threads: 4
Light Poster
yello is offline Offline
30 posts
since Nov 2006
Oct 16th, 2007
0

Re: join in select statement

It works thank you all for your help
this was the syntax that worked
ado1.recordset ("tblname.columnname")
Reputation Points: 10
Solved Threads: 16
Posting Whiz in Training
plusplus is offline Offline
207 posts
since Jul 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: loading setup in another computer
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: sorting a excel sheet using vb





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC