Sql
From Wiki
Using statement in command line for MySql
Accessing mysql
- Open command prompt and go to C:\xampp\mysql\bin directory
- Type mysql --user=root --password=
- Now you are connected and ready to use mysql DB
Commonly use sql statement
- Create Database -
<source lang="sql"> CREATE DATABASE db_name; </source>
- Select Database -
<source lang="sql"> USE db_name; </source>
- Show all tables -
<source lang="sql"> SHOW TABLES; </source>
- Show all tables -
<source lang="sql"> SHOW TABLES; </source>
- Show all columns -
<source lang="sql"> SHOW COLUMNS from table_name; </source>
How to join 3 tables
<source lang="sql"> select * from Student s inner join Person p on s.Person = p.Id inner join [User] u on u.Id = p.[User] where LcName = 'Makasar' </source>
How to update field for certain record
<source lang="sql"> UPDATE tbl_name SET col_1 = 'value1', col_2 = 'value2' WHERE col_id in ('col_id_1', 'col_id_2','col_id_3') </source>
- Example
<source lang="sql"> UPDATE [Subject] SET RateMyr = 750, RateUsd = 238 WHERE Code in ( 'LENG1043', 'LENG1053', 'LENG1013', 'LENG1023', 'LENG1322' ) </source>
SQL Server 2005
How to restore database
- Make sure your Database is only use by you, if there are other client using your database, you cannot overwrite the database.
Right click your DB, go to Properties and select Options. Change Restrict Access to SINGLE_USER
- Go to
- Select file to restore
- Select the version to restore
- Go to Option and Checked the Overwrite.
- Change the path at 'Restore AS' to point to your database file destination [db.log]





