Inserting last auto-generated ids

Vbanoob98

Board Regular
Joined
Sep 13, 2019
Messages
55
Yes thats very useful. How can I do this for lets say 200 rows instead of just 1? Or will this do it for all the rows?

And how could I join the result to my other table? :)
 

xenou

MrExcel MVP, Moderator
Joined
Mar 2, 2007
Messages
16,551
Office Version
2013
Platform
Windows
Possibly you are looking for something like this if you want to join two tables - where Table2 has the ID

Code:
select t2.ID, t1.Name, t1.Amount, t1.Address, t1,Total
 from Table1 t1
 inner join Table2 t2
on t1.Name = t2.Name
and t1.Amount = t2.Amount
and t1.Address = t2.Address
and t1.Total = t2.Total
 

Vbanoob98

Board Regular
Joined
Sep 13, 2019
Messages
55
Possibly you are looking for something like this if you want to join two tables - where Table2 has the ID

Code:
select t2.ID, t1.Name, t1.Amount, t1.Address, t1,Total
from Table1 t1
inner join Table2 t2
on t1.Name = t2.Name
and t1.Amount = t2.Amount
and t1.Address = t2.Address
and t1.Total = t2.Total
Thank you, I will try this tomorrow.
 

Vbanoob98

Board Regular
Joined
Sep 13, 2019
Messages
55
Possibly you are looking for something like this if you want to join two tables - where Table2 has the ID

Code:
select t2.ID, t1.Name, t1.Amount, t1.Address, t1,Total
from Table1 t1
inner join Table2 t2
on t1.Name = t2.Name
and t1.Amount = t2.Amount
and t1.Address = t2.Address
and t1.Total = t2.Total
I've been playing with this and it seems it requieres a unique identifier to work properly? Because when I put all the fields it just returns the headers.
 

Vbanoob98

Board Regular
Joined
Sep 13, 2019
Messages
55
I've been playing with this and it seems it requieres a unique identifier to work properly? Because when I put all the fields it just returns the headers.
I do have blank cells in both tables, Im guessing thats the issue
 

xenou

MrExcel MVP, Moderator
Joined
Mar 2, 2007
Messages
16,551
Office Version
2013
Platform
Windows
When you say it just returns the headers that means that the query resulted in no records (an empty set). That suggests that there is no match on the join criteria. You may need to examine one or two examples you think should be in the result and work out why they were excluded based on the join criteria. I'm doing a lot of guessing about your data - not able to say anything specific without an some sample data.
 

Forum statistics

Threads
1,081,678
Messages
5,360,462
Members
400,586
Latest member
Minty

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top