0% found this document useful (0 votes)
24 views

Create Table TBL

The document creates two tables, tbl_karyawan to store employee data and tbl_gaji to store salary data. It inserts sample data into the tables, updates some records, deletes a record, and runs a join query to retrieve salary and employee name, address, and city for a given period.

Uploaded by

Yepta Depari
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Create Table TBL

The document creates two tables, tbl_karyawan to store employee data and tbl_gaji to store salary data. It inserts sample data into the tables, updates some records, deletes a record, and runs a join query to retrieve salary and employee name, address, and city for a given period.

Uploaded by

Yepta Depari
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

create table tbl_karyawan

(
NIK int Primary Key,
Nama varchar (50) NULL,
Alamat varchar (50) NULL,
Kota varchar (50) NULL
)

create table tbl_gaji


(
ID_gaji int Primary Key identity,
NIK int CONSTRAINT [FK_tbl_gaji_tbl_karyawan] FOREIGN KEY(NIK)
REFERENCES dbo.tbl_karyawan (NIK),
Periode varchar (20) NOT NULL,
Jumlah_Gaji int NOT NULL,
)

insert into tbl_karyawan values


('10001','Alex','Jl. Banda no 10','Bandung');

insert into tbl_gaji values


('10001','Maret','5000000');

Update tbl_karyawan set Nama = 'Robert' where NIK ='10002';


Update tbl_karyawan set Kota = 'Surabaya' where NIK ='10005';
Update tbl_karyawan set Alamat = 'Jl.Tubagus No.8' where NIK ='10005';

Delete from tbl_karyawan where NIK ='10005';

SELECT dbo.tbl_gaji.Jumlah_Gaji, dbo.tbl_karyawan.NIK, dbo.tbl_karyawan.Nama,


dbo.tbl_karyawan.Alamat, dbo.tbl_karyawan.Kota

FROM dbo.tbl_gaji INNER JOIN

dbo.tbl_karyawan ON dbo.tbl_gaji.NIK = dbo.tbl_karyawan.NIK

WHERE (dbo.tbl_gaji.Periode = 'Maret')

You might also like