Showing posts with label sql/mysql. Show all posts
Showing posts with label sql/mysql. Show all posts
Assalamualaikum....

Hello everybody.....................

in database, we often create command-command function maybe with function we will be understand hoho. this is it,,, all example and basic command for sintaks sql.
this is juts to remember for anything was I do with writing I remember it :)

change name Table:
RENAME TABLE `campus`.`value` TO `campus`.`new_value` ;

change content field (name)
UPDATE `campus`.`colleger` SET `name` = 'kashif khan' WHERE `colleger`.`idcolleger` = 'c010';

delete data field (id=c001)
DELETE FROM `colleger`.`colleger` WHERE `colleger`.`idcolleger` = 'c001


show content table (table colleger)
Select * from colleger

show a few of data field (table student field id_student and field name)
Select id_student, name, from student;

show content field/record (table lesson with code l001)
SELECT * FROM `lesson` WHERE lesson.code_ls = 'l001'

counting data for table (table student) [menghitung jumlah data pada tabel]
select count(*) from student;    => (count(*) without spasi)

Add content a field (table tbl_value field value)
SELECT sum( value ) FROM tbl_value;  =>type of data should number

show content data between value (table tbl_value field value)
select * from tbl_value where value between 80 and 90;

sort content of data a field (table student field name)
SELECT * FROM `student` order by name asc;(asc => AZ, desc =>ZA)

show bebased character which you want (data character “JO”)
SELECT * FROM `student` WHERE name like '%jo%'; (mark % character in front of or in rear)

show bebased character what you want (side left)
SELECT * FROM `student` WHERE left(name,1)=’a’; (abdul, aan, ani dll)

show bebased character what you want (side right)
SELECT * FROM `student` WHERE right(name,1)=’i’; (ani, joni,kiki, dll)

show bebased character what you want (middle)
SELECT * FROM `student` WHERE mid(name,2,1)=’d’; (ade, ida, edo, dll)

for type data numeric(double, integer, dll)
show max value for table
Select max(value) from tbl_value;  (table tbl_value field value)

show min value for table
Select min(value) from tbl_value;  (table tbl_value field value)

show value average
Select avg(value) from tbl_value;  (table tbl_value field value)

show one group with one field
select * from student group by majority;

show one of data more 1 table
Select nametable.field, namatabel.field from tabel1, tabel2 where namatabel.field=namatabel.field;
SELECT siswa.nis, siswa.nama, tbl_nilai.nilai FROM siswa, tbl_nilai where siswa.nis=tbl_nilai.nis;

know about count data in a table with source of toher data
select count(*), siswa.nis, tbl_nilai.nis from siswa,tbl_nilai where siswa.nis=tbl_nilai.nis;  =>Jumlah yang muncul adalah sesuai record di table tbl_nilai

create new table for table in already use
create view RELASI_NILAI as select siswa.nis, siswa.nama, tbl_nilai.kode_mp, tbl_nilai.nilai from siswa,tbl_nilai where siswa.nis=tbl_nilai.nis;

show record of the end of table
select * from report order by id desc limit 1
Assalamualaikum....

Hello everybody. confused again with code programming? dont wory, because I have solution for you. taraaaa read this blog crackcoder.blogspot.com hohoho

before that, you should create file connection. save with name sqlconnection.php
if you was create file connection, we are now just call that file with...... include.....

dont worry, copy and paste code in the bellow.....

  <? include "sqlconnection.php";

$dsn="nama_database_sql"; //atau bebased name your DSN
$username="nama_user"; //atau bebased your username
$password="password"; //atau bebased your password
$koneksi= odbc_connect($dsn,$username,$password);
$sql="select * from nama_tabel"; //  basically sintaks sql and mysql is not different :)
$exec=odbc_exec($koneksi,$sql);
while(odbc_fetch_row($exec))
{
$id=odbc_result($exec,"id");
$employer=odbc_result($exec,"employer");
$majority=odbc_result($exec,"majority");
$gpa=odbc_result($exec,"gpa");
?>
design output, example I want design like this bellow, design as you wish... and this is just example :)
<table width="351" border="0">
   <tr>
    <td width="113">ID Calon Karyawan</td>
    <td width="21">:</td>
    <td width="203"><? echo $id_pelamar; ?></td>
  </tr>
  <tr>
    <td width="113">Nama Calon Karyawan</td>
    <td width="21">:</td>
    <td width="203"><? echo $calon_kar; ?></td>
  </tr>
   <tr>
    <td width="113">Jurusan Pelamar</td>
    <td width="21">:</td>
    <td width="203"><? echo $jurusan; ?></td>
  </tr>
   <tr>
    <td width="113">Lulusan Pelamar</td>
    <td width="21">:</td>
    <td width="203"><? echo $lulusan; ?></td>
  </tr>
   <tr>
    <td width="113">Ipk Pelamar</td>
    <td width="21">:</td>
    <td width="203"><? echo $ipk; ?></td>
  </tr>
</table><?
}
odbc_close($koneksi); ?>
save file with name, like "show.php then running that page in your browser localhost thennnnnnn yappp yapp yappp congratulation your sql now running. enjoy ngoding :)

Grettings crackcoder.blogspot.com

Assalamualaikum...
Hello everybody... this is a code to connection your sql server 2008 r2. upss dont worries to copy and paste this code, because I am free give it for you to learning :)


<?php
$server="name_server";
$username="name_username";
$password="password";
$database="name_database";
$conn = new COM("ADODB.CONNECTION")
or die("Sory its problem in your connection, please check ");
$connect = "PROVIDER=SQLOLEDB; SERVER=".$server."; UID=".$username."; PWD=".$password.";
DATABASE=".$database;
$conn->open($connect);
?>

after you copy and paste that code then save file name example the name file is 'config.php' then open in your browser with name file you create. and if the script was running be perfect so congratulation and enjoy to coding but if eror so check in your server name, user name, password and database name.

Salam Sugesti ^_^