Skip to content

Instantly share code, notes, and snippets.

@hidayat365
Created April 12, 2012 03:37
Show Gist options
  • Save hidayat365/2364464 to your computer and use it in GitHub Desktop.
Save hidayat365/2364464 to your computer and use it in GitHub Desktop.
Output MySQL
D:\xampp\mysql\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.5.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, 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.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use test;
Database changed
mysql> create table table_1 as
-> select 'MM001' noid, 'Andi' nama union all
-> select 'MM002' noid, 'Santi' nama ;
Query OK, 2 rows affected (1.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> create table table_2 as
-> select 'MM001' noid, '2012-02-28' tgl_beli union all
-> select 'MM002' noid, '2012-02-28' tgl_beli union all
-> select 'MM002' noid, '2012-03-30' tgl_beli ;
Query OK, 3 rows affected (0.18 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select table_1.*
-> from table_1
-> left join (
-> select * from table_2
-> where tgl_beli between '2012-03-01' and '2012-04-01'
-> ) table_2tmp
-> on table_1.noid = table_2tmp.noid
-> where table_2tmp.noid is null;
+-------+------+
| noid | nama |
+-------+------+
| MM001 | Andi |
+-------+------+
1 row in set (0.04 sec)
mysql>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment