Rabu, 27 November 2013

Menampilkan Data Tertentu dalam SQL













Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\thosiba>cd;..\..\

C:\>cd;xampp\mysql\bin;
The system cannot find the path specified.

C:\>cd;xampp\mysql\bin

C:\xampp\mysql\bin>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 83
Server version: 5.1.41 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| cdcol              |
| distro             |
| latihanfitri       |
| login              |
| majelisdzikir      |
| modeldb            |
| mysql              |
| pemesanan          |
| phpmyadmin         |
| spp                |
| stmikraharja       |
| test               |
| twitter            |
+--------------------+
14 rows in set (0.19 sec)

mysql> use stmikraharja;
Database changed
mysql> select*from mahasiswa;
+------------+---------------+--------+---------------+-------------------+
| nim        | nama          | kelas  | jenis_kelamin | alamat            |
+------------+---------------+--------+---------------+-------------------+
| 1114369610 | Wahyu Setiono | D3T134 | L             | Sudirman          |
| 1234567890 | Alam Pratama  | D3T134 | L             | Sudirman          |
| 1234567891 | Fitri Apriani | D3T134 | P             | Tamrin            |
| 1234567892 | Aminah        | D3T134 | P             | Sudirman          |
| 1234567893 | Aris Ridho    | D5T136 | L             | Solo              |
| 1234567894 | Aisyah r.h    | D5T136 | P             | Tamrin            |
| 1234567896 | Sri Wahyuni   | D3T134 | P             | Cikokol           |
| 1234567898 | Iswahyudi     | D3T134 | L             | Bandara Sukarno H |
| 1234567821 | Veny Febri    | D3T134 | P             | Balaraja Plosok   |
| 1234567822 | Eko Dwi Roso  | D5T136 | L             | Rajeg             |
+------------+---------------+--------+---------------+-------------------+
10 rows in set (0.00 sec)

mysql> select*from mahasiswa where jenis_kelamin='P' and (kelas='D3T134');
+------------+---------------+--------+---------------+-----------------+
| nim        | nama          | kelas  | jenis_kelamin | alamat          |
+------------+---------------+--------+---------------+-----------------+
| 1234567891 | Fitri Apriani | D3T134 | P             | Tamrin          |
| 1234567892 | Aminah        | D3T134 | P             | Sudirman        |
| 1234567896 | Sri Wahyuni   | D3T134 | P             | Cikokol         |
| 1234567821 | Veny Febri    | D3T134 | P             | Balaraja Plosok |
+------------+---------------+--------+---------------+-----------------+
4 rows in set (1.13 sec)

mysql> select*from mahasiswa where alamat='Sudirman' and alamat='Tamrin';
Empty set (0.00 sec)

mysql> select*from mahasiswa where alamat='Sudirman' or alamat='Tamrin';
+------------+---------------+--------+---------------+----------+
| nim        | nama          | kelas  | jenis_kelamin | alamat   |
+------------+---------------+--------+---------------+----------+
| 1114369610 | Wahyu Setiono | D3T134 | L             | Sudirman |
| 1234567890 | Alam Pratama  | D3T134 | L             | Sudirman |
| 1234567891 | Fitri Apriani | D3T134 | P             | Tamrin   |
| 1234567892 | Aminah        | D3T134 | P             | Sudirman |
| 1234567894 | Aisyah r.h    | D5T136 | P             | Tamrin   |
+------------+---------------+--------+---------------+----------+
5 rows in set (0.02 sec)

mysql> update mahasiswa set nama='Wahyu Setiono' where nama='Wahyu Setiono Updat
e';
Query OK, 0 rows affected (0.03 sec)
Rows matched: 0  Changed: 0  Warnings: 0

mysql> select * from mahasiswa where nim=1114369610;
+------------+---------------+--------+---------------+----------+
| nim        | nama          | kelas  | jenis_kelamin | alamat   |
+------------+---------------+--------+---------------+----------+
| 1114369610 | Wahyu Setiono | D3T134 | L             | Sudirman |
+------------+---------------+--------+---------------+----------+
1 row in set (0.00 sec)

mysql> update mahasiswa set nama='Wahyu Setiono ganti' where nim=1114369610;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from mahasiswa where nim=1114369610;
+------------+---------------------+--------+---------------+----------+
| nim        | nama                | kelas  | jenis_kelamin | alamat   |
+------------+---------------------+--------+---------------+----------+
| 1114369610 | Wahyu Setiono ganti | D3T134 | L             | Sudirman |
+------------+---------------------+--------+---------------+----------+
1 row in set (0.00 sec)

mysql> select*from mahasiswa where  kelas like'D3%';
+------------+---------------------+--------+---------------+-------------------
+
| nim        | nama                | kelas  | jenis_kelamin | alamat
|
+------------+---------------------+--------+---------------+-------------------
+
| 1114369610 | Wahyu Setiono ganti | D3T134 | L             | Sudirman
|
| 1234567890 | Alam Pratama        | D3T134 | L             | Sudirman
|
| 1234567891 | Fitri Apriani       | D3T134 | P             | Tamrin
|
| 1234567892 | Aminah              | D3T134 | P             | Sudirman
|
| 1234567896 | Sri Wahyuni         | D3T134 | P             | Cikokol
|
| 1234567898 | Iswahyudi           | D3T134 | L             | Bandara Sukarno H
|
| 1234567821 | Veny Febri          | D3T134 | P             | Balaraja Plosok
|
+------------+---------------------+--------+---------------+-------------------
+
7 rows in set (0.65 sec)

mysql> select nama,kelas from mahasiswa;
+---------------------+--------+
| nama                | kelas  |
+---------------------+--------+
| Wahyu Setiono ganti | D3T134 |
| Alam Pratama        | D3T134 |
| Fitri Apriani       | D3T134 |
| Aminah              | D3T134 |
| Aris Ridho          | D5T136 |
| Aisyah r.h          | D5T136 |
| Sri Wahyuni         | D3T134 |
| Iswahyudi           | D3T134 |
| Veny Febri          | D3T134 |
| Eko Dwi Roso        | D5T136 |
+---------------------+--------+
10 rows in set (0.01 sec)

mysql> WAHYU SETIONO Allhamdulilah selesai (^_^)

0 komentar:

Posting Komentar