Tampilkan data cuti pada range tanggal awal dan tanggal akhir selain tanggal cuti_bersama
Bismillah
q> Ini query sangat sederhana, dibuat ketika suasana otak sedang galau,
q> Pastinya ada query yang lebih keren dari pada ini
q> Buat database pada mysql
[sourcecode language="sql"]create database db_cuti[/sourcecode]
q> Buat tabel
[sourcecode language="sql"]create table tbl_cuti(no_cuti varchar(5) primary key, tgl_awal date, tgl_akhir date);[/sourcecode]
q> Insert data
[sourcecode language="sql"]insert into tbl_cuti values ('01', '2013-08-07', '2013-08-11' );[/sourcecode]
[sourcecode language="sql"]insert into tbl_cuti values ('02', '2013-08-10', '2013-08-16' );[/sourcecode]
[sourcecode language="sql"]insert into tbl_cuti values ('03', '2013-08-11', '2013-08-15' );[/sourcecode]
[sourcecode language="sql"]insert into tbl_cuti values ('04', '2013-08-12', '2013-08-15' );[/sourcecode]
q> Yuk nguery nguery
[sourcecode language="sql"]( select * from tbl_cuti where tgl_awal < '2013-08-10' and tgl_akhir < '2013-08-10' ) union all ( select * from tbl_cuti where tgl_awal > '2013-08-10' and tgl_akhir > '2013-08-10' )[/sourcecode]
Alhamdulillah
:D
masihGala();
No comments:
Post a Comment