We help IT Professionals succeed at work.
Get Started

Help with a Join Statement

directxBOB
directxBOB asked
on
201 Views
Last Modified: 2021-04-21
Actually I'm not 100% sure that I need a join on this, perhaps someone could advise me on this.

I have two tables:

Assets:

-ID
-AccountID
-SerialNumber
-AssetType
-ParentID


Assets History:

-ID
-AssetID (same ID from Assets table)
-TimeStamp
-Details

So I have these two tables

and I do:

Select * from Assets,AssetsHistory where  Assets.ID = AssetsHistory.AssetsID

This appears to get the resuts I need, but should I be doing an inner join or somethng?

I would also like to do 2 queries from Asset History :

1. Get the First Entry against an AssetID (so I get the first time I stored something against an asset in the asset history table)

2. Get the last Entry against an AssetID.

I have no idea how I woul pull it off, but it would be good if I could merge the above two with my initial statement.

So that I am getting.

-ID
-AccountID
-SerialNumber
-AssetType
-ParentID
-FirstEntry
-LastEntry

Any helpe would be great. Worst case scenario I'll have 3 statements ad handle the rest in code using datasets.
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE