Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

I want insert record with start date end date from company table to transactions table in sql

Rajnish Pandey
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 24, 2025

I have two table in SQLserver 
Company table
Transactions table
Company table
___________________________________
CId _ Name _ StartDate _ EndDate
____|________________________________

      1      |    ABC   |     01/04/2024  | 31/03/2025

    And 2and table have 

Transactions table 


___________________________________
Tid _ Description _ Transactions date
____|________________________________

      1      |    Expense  |       |      3/01/2025

    I want to insert record when transactions table date matches from  company table  date range then Insert record 

If not match record not saved 

If  

Tid _  Description _  Transactions date 
____|________________________________

      1      |    Expense  |       |      22/01/2027

Date range not over lapping  

 

 

 

 

1 answer

0 votes
Mirek
Community Champion
January 28, 2025

Hello @Rajnish Pandey 

If I understand correctly maybe it would be something like this? 

INSERT INTO Transactions (Tid, Description, TransactionDate) 
SELECT 1, 'Expense', '2025-01-03'
WHERE EXISTS (
SELECT 1 FROM Company
WHERE '2025-01-03' BETWEEN StartDate AND EndDate
);

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, confluence, loom, atlassian intelligence, ai notes, ai-powered meeting notes, atlassian community events, ace, confluence ai, loom ai integration, ai note-taking, atlassian ai features, team '25, atlassian live learning, confluence automation

Unlock AI-powered meeting notes: Join our live learning session! 📹

Did you catch the news at Team ‘25? With Loom, Confluence, Atlassian Intelligence, & even Jira 👀, you won’t have to worry about taking meeting notes again… unless you want to. Join us to explore the beta & discover a new way to boost meeting productivity.

Register today!
AUG Leaders

Atlassian Community Events