Skip to content

Instantly share code, notes, and snippets.

@hidayat365
hidayat365 / kulgram-inventory-quiz.sql
Last active May 18, 2023 02:35
script sql untuk tantangan membuat query kartu stok
-- tabel master barang
create table items (
id int auto_increment not null,
code varchar(50) not null,
name varchar(200) not null,
primary key (id),
constraint ak_items unique key (code)
);
-- tabel transaksi barang masuk
@hidayat365
hidayat365 / kulgram-sql-join.sql
Last active November 3, 2021 04:49
Script praktek dan latihan SQL JOIN di KulGram PHP Indonesia
create table students (
id serial primary key,
code varchar(20) not null,
name varchar(200) not null
);
create table courses (
id serial primary key,
code varchar(20) not null,
name varchar(200) not null
@hidayat365
hidayat365 / sender.php
Last active November 20, 2015 04:44
SMS Sender ID Helper
<?php
function referrals_sms_sender($msisdn=FALSE, $message=FALSE, $uid=FALSE)
{
global $user;
set_time_limit(0);
if ($msisdn and $message) {
// parameter
$hp = urlencode(htmlspecialchars($msisdn));
$msg = urlencode(htmlspecialchars($message));
@hidayat365
hidayat365 / web.config
Created September 11, 2015 08:11
Setting web.config untuk Yii2 basic
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<connectionStrings>
<add connectionString="server=ap-cdbr-azure-southeast-a.cloudapp.net;User Id=user;database=proxima3;password=pass" name="proxima3" providerName="MySql.Data.MySqlClient" />
</connectionStrings>
<system.webServer>
<rewrite>
<rules>
<rule name="Yii2 WebApp Redirect" stopProcessing="true">
<match url="^$" />
@hidayat365
hidayat365 / output.txt
Created November 11, 2014 17:22
Contoh Penggunaan LEFT JOIN dan COALESCE
mysql> create table tbl_inti as
-> select '001' nik, 'Aria' nama union all
-> select '002' nik, 'Budi' nama union all
-> select '003' nik, 'Cici' nama union all
-> select '004' nik, 'Dina' nama union all
-> select '005' nik, 'Elia' nama union all
-> select '006' nik, 'Fandi' nama union all
-> select '007' nik, 'Gina' nama union all
-> select '008' nik, 'Hari' nama union all
-> select '009' nik, 'Icha' nama union all
@hidayat365
hidayat365 / unionsample.sql
Created May 19, 2014 06:20
UNION ALL sample
mysql> use test;
Database changed
mysql> drop view if exists qry_labarugi ;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> create view qry_labarugi as
-> SELECT year(tanggal) AS tahun
-> , month(tanggal) AS bulan
-> , SUM(total_jual) AS total
@hidayat365
hidayat365 / tuning1.sql
Last active January 25, 2024 23:36
Simple SQL Query Performance Tuning using INDEX
E:\xampp\mysql\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.36 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
@hidayat365
hidayat365 / crosstab5.sql
Last active August 29, 2015 14:01
Another MySQL Cross Tab or Pivot Table
F:\xampp\mysql\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.36 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
@hidayat365
hidayat365 / installment.sql
Created April 29, 2014 09:57
Query untuk menjumlahkan pembayaran installment
select tahun, bulan, sum(payment) as payment
from (
select year(payment1_dt) tahun, month(payment1_dt) bulan, payment1 payment from tb_dtinstallment
union all
select year(payment2_dt) tahun, month(payment2_dt) bulan, payment2 payment from tb_dtinstallment
union all
select year(payment3_dt) tahun, month(payment3_dt) bulan, payment3 payment from tb_dtinstallment
union all
select year(payment4_dt) tahun, month(payment4_dt) bulan, payment4 payment from tb_dtinstallment
union all
@hidayat365
hidayat365 / crosstab.txt
Created April 9, 2014 05:19
Another Dynamic MySQL Cross Tab
Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.
C:\Users\Nur>d:
D:\>cd xampp
D:\xampp>cd mysql\bin
D:\xampp\mysql\bin>mysql -u root