query tanggal awal dan tanggal akhir selain tanggal tertentu

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

create database db_cuti

q> Buat tabel

create table tbl_cuti(no_cuti varchar(5) primary key, tgl_awal date, tgl_akhir date);

q> Insert data

insert into tbl_cuti values ('01', '2013-08-07', '2013-08-11' );
insert into tbl_cuti values ('02', '2013-08-10', '2013-08-16' );
insert into tbl_cuti values ('03', '2013-08-11', '2013-08-15' );
insert into tbl_cuti values ('04', '2013-08-12', '2013-08-15' );

q> Yuk nguery nguery

( 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' )

Alhamdulillah

😀

masihGala();

Published by

saifiahmada

Begin a big Process with a bit trying

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s