Best Jquery ,javascript, HTML5 CSS3 tutorial with jquery examples, php script , demos for beginners, web designers and web developers.

Jquery

Jquery, javascript Training

Jquery training blog

Useful MySql statement and commands

how to create a database in mysql

 create database [database name];

how to List all databases on the server.

 show databases;

How to switch to a perticular database.

use [db name];

To see all the tables in the database.

show tables;

How to see field formats of a table.

describe [table name];

How to delete a mysql db.

drop database [database name];

How to delete a table.

drop table [table name];

Select all records from a table.

SELECT * FROM [table name];

To return columns and column information.

show columns from [table name];

Select records from a table by field value

SELECT * FROM table name WHERE [field name] = "value";

Show all records containing the name “Something” AND the phone number ‘1001001001’.

SELECT * FROM [table name] WHERE name = "Something" AND phone_number = '1001001001';

Show all records not containing the name “Something” AND the phone number ‘1001001001’ order by the phone_number field.

SELECT * FROM [table name] WHERE name != "Something" AND phone_number = '1001001001' order by phone_number;

Show all records starting with the letters ‘Something’ AND the phone number ‘1001001001’.

SELECT * FROM [table name] WHERE name like "Something%" AND phone_number = '1001001001';

Show all records starting with letters AND the a field with value ‘abc@d.com’ limit to records 1 through 5.

SELECT * FROM [table name] WHERE name like %letters %" AND email = 'abc@d.com' limit 1,5;

How to show unique records from mysql table

SELECT DISTINCT [column name] FROM [table name];

Show selected records sorted in an ascending (asc) or descending (desc).

SELECT [colm1],[colm2] FROM [table name] ORDER BY [colm1] DESC;

How to count number of rows.

SELECT COUNT(*) FROM [table name];

How to find the sum column.

SELECT SUM(column name) FROM [table name];

How to copy a table to another table in MySql
INSERT INTO `table2` SELECT * FROM `table1`;

Please follow and like us:





Got Something To Say:

Your email address will not be published. Required fields are marked *

*


About the author

Joydeb Choudhury holds a Master's degree in Computer Application from I.G.N.O.U. After working as a web developer in various companies he has started bloging in 2016.

Recent Posts of blog

Downalod Free Php Scripts