[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

SQL Select ,Insert with multiple value

I have 2 table 1) Tenant ------primarykey
2) CalenderEvent-------TenantID,CalnderEvent

select t.primaryKey from tenants T,tenantRentals TR where tr.tenantID = t.primaryKey and tr.leaseEndDate > GETDATE()

from tenant table I am getting primarykey afcourse it is multiple value and  all this values

II want to insert in calender table as TenatID and also wants to insert same calender event for all TenantID.Is there any way I can do it....

Please let me know....
0
Itgirl16
Asked:
Itgirl16
1 Solution
 
johanntagleCommented:

insert into CalendarEvent (TenantID, CalnderEvent)
select t.primaryKey, ColumnForCalendEvent
from tenants T, tenantRentals tr
where tr.tenantID = t.primaryKey and tr.leaseEndDate > GETDATE();

Is that what you need?
0
 
appariCommented:
try like this
Insert into CalenderEvent(TenantID,CalnderEvent)
select t.primaryKey, 'EventValue' 
from tenants T,tenantRentals TR where tr.tenantID = t.primaryKey and tr.leaseEndDate > GETDATE()

Open in new window

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now