Anda di halaman 1dari 10

MODUL REFERENSI SISTEM BASIS DATA

SQL
MySQL on Ubuntu

DEPARTEMEN TEKNIK INFORMATIKA UNIVERSITAS NASIONAL


UpdateJuni2011

Informasi: SistemOperasi:LinuxUbuntu10.10 Database:MySqlServer5.1

MENGGUNAKANPERINTAHSELECT Sintaks:SELECTNamaKolom1,NamaKolom3.FROMNamaTabel; contoh:SELECTMemberId,FirstNameFROMMemberDetails; berikutgambarnyadibawahini:

lalucobaketikperintahdibawahini:
SELECTStreet,City,StateFROMMemberDetails;

sayainginmengambilKolomdengannamaCity Makaakanterlihatsepetiini(menampilkannamakotadarisetiapmember) SELECTCityFROMMemberDetails;

Jikamenggunakanperintahinidengankeyword:DISTINCT SELECTDISTINCTCityFROMMemberDetails; makahasilnyaakansepertiini

SELECTDISTINCTCity,MemberIdFROMMemberDetails;

Yuk...MarikitaINSERTdatalagi

yukkitaikutilagiperintahdibawahini Sintaks:
INSERTINTOMemberDetails(MemberId,FirstName,LastName, DateOfBirth,Street,City,State,ZipCode,Email,DateOfJoining) VALUES(10,'Susie','Simons','1937120','MainRoad','Townsville', 'MegaState','123456','susie@mail.com','20050820'); INSERTINTOMemberDetails(MemberId,FirstName,LastName, DateOfBirth,Street,City,State,ZipCode,Email,DateOfJoining) VALUES(11,'Jamie','Hill','19670220','NewishLane','Orange Town','NewState','14045','jam@jamie.com','20050812');

CaramengubahisianKolom Sintaks:UPDATENamaTabelSETNamaKolom=ekspresi WHEREKondisi;

UPDATEMemberDetailsSETEmail="William@mailme.com" WHEREMemberId="13"; lalulihathasilnya

INSERTINTOFavCategory(CategoryId,MemberId)VALUES(3,10); INSERTINTOFavCategory(CategoryId,MemberId)VALUES(6,10); INSERTINTOFavCategory(CategoryId,MemberId)VALUES(4,11); INSERTINTOFavCategory(CategoryId,MemberId)VALUES(3,11); INSERTINTOFavCategory(CategoryId,MemberId)VALUES(5,11);

INSERTINTOFavCategory(CategoryId,MemberId)VALUES(1,12); INSERTINTOFavCategory(CategoryId,MemberId)VALUES(4,12); INSERTINTOFavCategory(CategoryId,MemberId)VALUES(6,12); INSERTINTOFavCategory(CategoryId,MemberId)VALUES(3,13); INSERTINTOFavCategory(CategoryId, MemberId)VALUES(5,13); INSERTINTOFavCategory(CategoryId, MemberId)VALUES(2,14); INSERTINTOFavCategory(CategoryId, MemberId)VALUES(6,14);

INSERTINTOFilms (FilmId,FilmName,YearReleased,PlotSummary,AvailableOnDVD,Rating, CategoryId) VALUES (9,'OnemanOneDollar',1999,'life','Y',2,3);

INSERTINTOFilms(FilmId,FilmName,YearReleased,PlotSummary, AvailableOnDVD,Rating,CategoryId)VALUES(10,'KetikaCintaBertasbih',2008, 'life','N',4,1); INSERTINTOFilms(FilmId,FilmName,YearReleased,PlotSummary, AvailableOnDVD,Rating,CategoryId)VALUES(11,'LaskarPelangi',2008,'life', 'Y',2,1); INSERTINTOFilms(FilmId,FilmName,YearReleased,PlotSummary, AvailableOnDVD,Rating,CategoryId)VALUES(12,'DalamMihrabCinta',2008,'life', 'Y',3,1); INSERTINTOFilms(FilmId,FilmName,YearReleased,PlotSummary, AvailableOnDVD,Rating,CategoryId)VALUES(13,'SangPemimpi',2008,'life', 'Y',5,1); INSERTINTOFilms(FilmId,FilmName,YearReleased,PlotSummary, AvailableOnDVD,Rating,CategoryId)VALUES(14,'SiKabayan',2008,'life','Y',6,1);