| | |
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:
Solved Threads: 16
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?
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?
•
•
Join Date: Nov 2006
Posts: 30
Reputation:
Solved Threads: 4
Try this query.
adobau.RecordSource = "SELECT Liegenschaften.name,Liegenschaften.address,tblbau.date FROM Liegenschaften INNER JOIN tblbau ON Liegenschaften.Rimo_Liegnr = tblbau.Liegenschaft"
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
Make Your Programing Easy
•
•
Join Date: Aug 2007
Posts: 56
Reputation:
Solved Threads: 1
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
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
•
•
Join Date: Jul 2007
Posts: 189
Reputation:
Solved Threads: 16
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?
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?
•
•
Join Date: Nov 2006
Posts: 30
Reputation:
Solved Threads: 4
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
Make Your Programing Easy
![]() |
Similar Threads
- Hi,Need help on sql select statement structure (MS SQL)
- Question about select statement (MySQL)
- Question about SELECT statement (MySQL)
- Getting current value in Select Statement (MS SQL)
- Program Problem with a select statement to access Data base (C)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: loading setup in another computer
- Next Thread: sorting a excel sheet using vb
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






