One of the most important syntax in SQL is select. Select function to display the data in the tables contained in the database. This is where there are many differences between regular SQL and Oracle SQL. Oracle lot summarizes syntax into simpler syntax although also remain memerima oracle SQL strandar.
SELECT
[tb1].[nama_kolom1],
[tb2].[nama_kolom2], . . .
FROM
[nama_tabel1] [tb1],
[nama_tabel2] [tb2]
WHERE
[kondisi_join]
[operator_boolean] [kondisi_select]
ORDER BY [nama_kolom_order]
GROUP BY [nama_kolom_group];
Description:
tb: Alias of [nama_tabel1]
nama_kolom: Name columns to display
kondisi_join: If the FORM clause there are two or more tables then there should be this condition is menjoinkan table-table in clause
operator_boolean: operator-like kondisi_join operator for AND and OR
kondisi_select: Conditions addition to perfecting this SELECT operation. Usually using comparison operations, such as:>, <,> =, <=, BETWEEN, <>
nama_kolom_order: SELECT results to the sort by the nama_kolom.
nama_kolom_group: SELECT Results to nama_kolom classified based. So all the records of the same value will be issued only one record only. Noteworthy is that all fields must be in the SELECT GROUP BY a.
Before clarified with an example is better for us to fill the data for the tables we have made in the article Create Table "Teaching-Learning System" - (Analysis & Design). Script to fill in the data please download it here.
1. Displaying all students with grade I sorted by student name.
SELECT
NAMA,
ALAMAT
FROM
TEST.MURID
WHERE
KELAS_ID = ‘I’ /*[kondisi_select]*/
ORDER BY NAMA, NIS; /*[nama_kolom_order]*/
2. Displaying the teachers who teach biology.
SELECT
g.NIG,
b.NAMA
FROM
TEST.GURU g,
TEST.BELAJAR b
WHERE
g.NIG = b.NIG /*[kondisi_join]*/
AND b.KODE_MP = ‘DA0007′ /*[kondisi_select]*/
GROUP BY g.NIG, g.NAMA; /*[nama_kolom_group]*/
0 comments:
Post a Comment