Friday, November 9, 2007

Syntax SQL for querying database

SQL (Structured Query Language) is a small-language that we can use to manipulate a database. In real life, SQL equivalent with lingua-france (language of trade).
Almost database application recognize this language.
So, if we good in this language, it very useful for our application that related with database. Of cource, most application related with database.

Suppost we have table: "data_pegawai"
here the record...
nip nama alamat usia gender
001 joko depok 50 L
002 soni bogor 35 L
003 dewi jakarta 20 P
004 rudi depok 30 L

here...some SQL syntax...

if we want to display all record...
"select * from data_pegawai"
if we want to display only nip and nama...
"select nip,nama form data_pegawai"
if we want to display person who only usia > 30...
"select * from data_pegawai where usia > 30"
if we want to display only alamat in depok...
"select * from data_pegawai where alamat='depok'"
if we want to know how many person in each alamat...
"select alamat,count(alamat) as jumlah from data_pegawai group by alamat"

...that's an example....i will continue later...

No comments: