Showing posts with label SQL statement. Show all posts
Showing posts with label SQL statement. Show all posts

Sunday, January 11, 2009

SQL Statement #2

Oke, lets try another SQL Statement.
i was publis little SQL Statement before...
click here if you want to see..

In this tutorial, we will include SQL statement to VB Program.
Actually, we can use any database manipulation by regular

expression or arithmatic expression, but with this way, it tooks
many code and not efficienct.

So, SQL statement simplify our way.

Suppose we have this table:
table name: member
-----------------------------
code name city age
-----------------------------
001 john depok 17
002 erica bogor 20
003 sony jakarta 18
004 wawan depok 16
005 jojo depok 25
-----------------------------

oke, case study:
1. if we to add data...
sql="insert into member values('006','dewi','bogor','18')"
means: add record, code=06, name=dewi, city=bogor, age=18

2. if we want to update data...
sql="update member set name='eric' where code='002'"
means: change erica name into eric

3. if we want to delete data...
sql="delete from member where code='005'"
means: delete the recorde that its code=005

oke, i assume we use adodc1 to connect the database, so how to
embeded SQL statement?
here is the code:

sql="..." [look at each case study above]
adodc1.recordsource=sql
adodc1.refresh


oke, that SQL statement @ glance we'll continue later...

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...