...

View Full Version : multiple tables



parallon
02-23-2006, 11:08 PM
Hello all. I was just wondering whether it is possible to have data from 2 differrent database tables in the same form table, or do I need to create another form table?

Thanks,

Parallon

Brandoe85
02-23-2006, 11:12 PM
Can you explain in more detail? I don't quite understand.

Thanks,

parallon
02-23-2006, 11:28 PM
Well, the program that I am working on generates a report which has a section called 'Estimates'. Well in this section, there is a list of Equipment with data pertaining to each piece of equipment, i.e. description, type, cost, etc. (All from the same table)... I am trying to add one more bit of information, but this info is coming from a different table in the database. I was just wondering if it is possible to include that data in the same row as the other relevant information? I would post the code, but there are about 820 lines.

Thanks,

Parallon

Brandoe85
02-23-2006, 11:39 PM
Do these 2 tables relate so you could use a join? What DBMS are you using?

parallon
02-24-2006, 12:05 AM
I really appreciate your effort, but the easiest thing that I think that I could do is to attach the file. BTW, this is a SQL database. What I am trying to do is use the field "Room" from a table called 'Equipment', and associate it to the appropriate equipment. The other fields in this section are coming from a table called 'WOtools'. I have created a space where I need the data on line 427. I am not asking for you to do it for me, but if you could just point me in the right direction.

Thanks,

Parallon

parallon
02-24-2006, 07:13 PM
Ok, here is the portion getting some of the information:


sSQL = "SELECT * FROM WOTools WHERE KeyNum = '" & wonum & "' AND Estimate <> 0 ORDER BY Equipment"
Set rsTool = conn.Execute(sSQL)

What I need also is to get the record from Equipment.Room. Both the Equipment and WOTools tables have a field called Equipment. Could I just use a LEFT JOIN to get this information also?

Thanks,

Parallon

Brandoe85
02-27-2006, 09:38 PM
Depends what kind of matches you need. Either INNER join or a LEFT join. Heres an article on joins:
http://www.w3schools.com/sql/sql_join.asp

Let us know how it goes.

Good luck;

parallon
02-27-2006, 09:45 PM
Thank you for your effort. I finally got it with the following method:


sSQL = "SELECT WOTools.*, Equipment.Room FROM WOTools LEFT JOIN Equipment ON WOTools.Equipment = Equipment.Equipment WHERE KeyNum = '" & wonum & "' AND Estimate <> 0 ORDER BY Room"

Once again, thank you all.

Parallon



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum