Menampilkan data pada 2 tabel dengan jumlah baris berbeda

207 views
Skip to first unread message

Mas' Kusmadi

unread,
Oct 4, 2012, 4:42:56 AM10/4/12
to mysql-i...@googlegroups.com
mysql> select * from setor;
+-----+--------+-------+------------+---------+
| idS | idUser | noreg | tanggal | nominal |
+-----+--------+-------+------------+---------+
| 1 | 4 | 12345 | 27/9/2012 | 5000 |
| 2 | 123 | 12346 | 27/09/2012 | 20000 |
| 3 | 123 | 12345 | 27/09/2012 | 15000 |
| 4 | 123 | 12345 | 27/09/2012 | 50000 |
| 5 | 123 | 12346 | 27/09/2012 | 75000 |
| 6 | 123 | 12346 | 27/09/2012 | 25000 |
| 7 | 123 | 12345 | 27/09/2012 | 65000 |
| 8 | 123 | 12345 | 27/09/2012 | 5000 |
| 9 | 123 | 12345 | 27/09/2012 | 9000 |
+-----+--------+-------+------------+---------+
9 rows in set (0.00 sec)

mysql> select * from ambil;
+-----+--------+-------+------------+---------+
| idA | idUser | noreg | tanggal | nominal |
+-----+--------+-------+------------+---------+
| 1 | 123 | 12345 | 03/10/2012 | 2000 |
| 2 | 123 | 12346 | 03/10/2012 | 5000 |
| 3 | 123 | 12345 | 03/10/2012 | 5000 |
| 4 | 123 | 12346 | 03/10/2012 | 5000 |
| 5 | 123 | 12345 | 03/10/2012 | 10000 |
| 6 | 123 | 12346 | 03/10/2012 | 9000 |
+-----+--------+-------+------------+---------+
6 rows in set (0.00 sec)

Gimana cara menampilkan tanggal dan nominal dari ke 2 tabel tersebut sesuai dengan jumlah barisnya? Yang bisa bantu di komentar ya. Trims

Fajar A. Nugraha

unread,
Oct 16, 2012, 9:08:58 PM10/16/12
to mysql-i...@googlegroups.com
2012/10/4 Mas' Kusmadi <jackle...@gmail.com>:
Mesti tentukan dulu, output yang diinginkan gimana. Contoh, kalo cuma
mau "semua setor dan ambil ditampilkan di satu tabel", coba UNION.

--
FAN

rafi randoni

unread,
Oct 19, 2012, 12:31:16 PM10/19/12
to mysql-i...@googlegroups.com
kenapa engga pake join aja om???
hehe, sbener'a saya kurang ngerti ma pertanyaan'a.. :D
> --
> Untuk memposting, kirim email ke mysql-i...@googlegroups.com |
> Untuk unsubscribe, kirim email ke
> mysql-indones...@googlegroups.com | Arsip milis :
> https://groups.google.com/d/forum/mysql-indonesia?hl=id
>
>
>
Reply all
Reply to author
Forward
0 new messages