Categories
MySQL

MySQL SELECT Statement

Using MySQL SELECT statement you can fetch combination of columns and rows from tables or views, known as a result set. This is the one of the most commonly used queries in MySQL to get data from the MySQL database. You can add or use one or more tables i.e. separated by comma for including various […]

Categories
MySQL

MySQL BETWEEN & Alias

To specify a range of test you can use BETWEEN operator. Example of BETWEEN: SELECT * FROM users WHERE age BETWEEN 18 AND 55; Here below 18 and above 55 aged user will be eliminated. For your own understand you can give an alias name to a column while getting the data from a table. […]

Categories
MySQL

MyISAM vs Innodb

MyISAM vs Innodb – both are commonly used engines on MySQL servers and they both have their unique advantages and disadvantages against each other. MyISAM is the default storage engine type for MySQL 5.0 but the Cloud Sites environment defaults the storage engine to Innodb. MyISAM vs Innodb: MyISAM: Table level locking.Innodb: Row level locking. […]

Categories
MySQL

MySQL GROUP BY & HAVING clause

To group rows into subgroup by one or more values of columns we use MySQL GROUP BY. Suppose in user table same country name exists for many times for different user. So if we use GROUP BY for country column to a SELECT query then only unique country will be listed. EXAMPLE: SELECT * FROM […]

Categories
MySQL

MySQL CREATE TABLE

Using CREATE TABLE statement in MySQL you can create a table into the database. The following example shows the statement in the simple form: CREATE TABLE Format: CREATE TABLE IF NOT EXISTS `tbl` ( tbl_id int(11) NOT NULL AUTO_INCREMENT, tbl_title varchar(100) DEFAULT NULL, post_date DATE DEFAULT NULL, update_date DATE DEFAULT NULL, PRIMARY KEY (tbl_id) ) […]

Categories
MySQL

Intro: MySQL Stored Procedures

A segment of declarative SQL statements which is stored inside the database catalog is called stored procedures, invoked by a triggers. Advantages: When stored procedures are created it is compiled and stored in the database so that when it is called multiple times then the compiled version is used. It is very secure. It is […]

Categories
MySQL

MySQL temporary table

To store a temporary result set you can use a special type of table i.e. called MySQL temporary table. To keep temporary data, the temporary tables could be very useful in some cases. When the current client session terminates, the temporary tables is deleted. This is useful for stored procedures, join query etc. Temporary tables […]

Categories
MySQL

Mysql update fields with random sentence

Sometimes we need to add demo text in a website for checking whether it working fine or somewhere we test website with demo text. So on this case unwanted text inserted into database and you need to remove it. So, we can update fields with random sentence in this case. For example the fields value […]

Categories
MySQL

MySQL IN Operator

Using IN operator in MySQL you can match the value from a set of values or a subquery. Example of MySQL IN: SELECT * FROM user WHERE country IN (‘IN’,’AUS’); Here both the user from IN and AUS will be shown in the result. You can also check for exception like: SELECT * FROM user […]

Categories
MySQL

MySQL ALTER TABLE, DROP TABLE

To change the structure of a table you use ALTER TABLE statement. This allows you to add or drop column, change data type, rename table etc. Example of ALTER TABLE: ALTER TABLE table_name CHANGE COLUMN table_id table_id INT(11) NOT NULL AUTO_INCREMENT; To remove existing table you need to use DROP TABLE statement as below: Example […]