Kumpulan & rumus syntak sql
1. Insert => Insert Into Table values(values1,... valuesN);
2. Update => Update nama_table set nama_field="field_baru" where kondisi;
3. Delete => Delete From nama_table where kondisi;
4. Between => Select * from nama_table where nama_field between values1 and values2;
5. Alter Add => Alter table nama_table Add field_baru tipedata(panjang_data);
6. Alter Modify => Alter table nama_table Modify nama_field Tipedata(panjang_data);
7. Alter Drop => Alter table nama_table drop nama_field;
8. Alter Rename => Alter table nama_table_lama Rename to Nama_table baru;
9. Truncate => Truncate Table nama_table;
10. View => Create View nama_view as statement_sql_select;
11. Inner Join => Select * from table1 inner join table2 on table1.pk = table2.fk;
12. Union Join => Select * from table1 left join table2 on table1.pk = table2.fk Union all select * from table1 right join table2 on table1.pk = table2.fk;
13. Cross Join => Select * from Table1 cross join table2;
14. Right Outer Join => Select * from table1 right outer join table2 on table1.pk = table2.fk;
15. Left Outer Join => Select * from table1 left outer join table2 on table1.pk = table2.fk;
16. Distinct => Select Distinct(nama_field) from nama_table;
17. Order By => Select * from nama_table order by nama_field asc/desc;
18. Like (Depan) => Select * from nama_table where nama_field like 'Huruf%';
19. Like (Tengah) => Select * from nama_table where nama_field like '%Huruf%';
20. Like (Belakang) => Select * from nama_table where nama_field like '%Huruf';
21. - Not => Select * from nama_table where nama_field not ='kondisi';
- And => Select * from nama_table where kondisi1 and kondisi2;
- Or => Select * from nama_table where kondisi1 or kondisi2;
22. Create Table => Create table nama_table(nama_field tipedata(panjang_data));
23. Constraint Update Cascade => Create table nama_table(nama_field tipedata(panjang_data), foreign key(nama_field) refrences nama_table on Update cascade);
24. Alter Add Constraint => Alter table nama_table add Constraint nama_Constraint;
25. Constraint Delete Cascade => Create table nama_table(nama_field tipedata(panjang_data), foreign key(nama_field) refrences nama_table on Delete cascade);
26. Group By Having => Select field1, field2...fieldN from nama_table having agregate_function(expression)condition;
27. Group By => Select field1, field2.. .fieldN from nama_table group by field_acuan;
28. - Sum => SELECT Sum(nama_field) FROM nama_tabel;
- Max => SELECT Max(nama_field) FROM nama_tabel;
- Min => SELECT Min(nama_field) FROM nama_tabel;
- Avg => SELECT Avg(nama_field) FROM nama_tabel;
29. Single Subquery => Select Field1,... FieldN from nama_table where nama_field kondisi_operator_perbandingan(Select nama_field from nama_table where kondisi);
30. Multiple Subquery(In) => Select Field1,... FieldN from nama_table where nama_field in(Select nama_field from nama_table where kondisi);
31. Multiple Subquery(Any) => Select Field1,... FieldN from nama_table where nama_field < any(Select nama_field from nama_table where kondisi);
32. Multiple Subquery(All) => Select Field1,... FieldN from nama_table where nama_field > all(Select nama_field from
No comments: