Jump to content
Sign in to follow this  
Furek86

SQL querying two tables - issue

Recommended Posts

Furek86

Hi everyone.

I have been recently working with Autoit trying to manage an MS SQL Database. I have successfully connected to it and ran few queries. However now I am facing an issue. Let me explain:

I have two tables in my base: tblAssets & tblBuildings.

tblAssets contains records regarding a specific asset, but there are only two that are needed in this case - Description (assets description) & BuildingID (a specially generated ID of a building the asset is in).

tblBuildings contains also two records I am intrested in - Description (building description) & BuildingID (a specially generated ID of a building the asset is in). The problem is:

I want to use a query that will query those two tables and retrieve Asset's Description from tblAssets and Building's Description from tblBuildings.

I noticed that when I use a recordset, autoit returns an error when trying to use for instance $rs.Fields("tblBuildings.Description").value..

Any ideas how to resolve this?

Share this post


Link to post
Share on other sites
zorphnog

Post the relevant code that you have including the query and the recordset value retrieval that you are having an issue with. We can't help you without more information.

Edited by zorphnog

Share this post


Link to post
Share on other sites
tehdon

I think the recordset returned from the query will contain just the column names even though you are joining two tables. So the record you are attempting to access would actually be name 'Description', not 'tblBuildings.Description'.

Try referencing $rsFields("Description").value and see if that gets you past the error.

If you have two identically named columns in the tables being joined, rename one or both using the AS statement in the SELECT statement.

Share this post


Link to post
Share on other sites
Furek86

Thanks Tehdon :idea: Now my query works perfectly :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×