Most Essential And Frequently Asked Interview Questions And Answer
OPTIMIZE command is use for optimize a table.
OPTIMIZE TABLE `users`
For increaseing the speed of a query we have to do couple of things
DATEDIFF function is use for finding the number of days between two given dates using MySQL
Bellow code is use for the same
$sql = "SELECT * FROM table1"; $result = mysql_query($sql, $db_link); $num_rows = mysql_num_rows($result); echo $num_rows;
View in SQL is a kind of virtual table. It does not physical exists in our database but have rows and column as there we have in real database table. we can create a view by selecting fields from one or tables present in the database. A View can have all the rows of a table or specific rows based on certain condition.View Detials
We can use bellow query to count number of rows in a table
>SELECT COUNT(*) FROM table_name;
The BETWEEN operator select all records between the given range whereas IN operator select all matching records given with WHERE clause.View Detials
The LIKE operator of SQL is used for such kind of operations. It is used to fetch filtered data by searching for a particular pattern in where clause.View Detials
There are 5 different types of storage engine present in MySql.
MyISAM is the default storage engine for MySQL
Mostly we use:
utf8_general_ci is use for fast sorting but it is less accurate whereas utf8_unicode_ci is used for better accuracy but little slow as compare to utf8_general_ci.
We can also use other collation based on specific languages like utf8_swedish_ci.
There is only one primary key in a table. It creates the cluster index automatically and it cannot have NULL value
where as there can be multiple unique constraints in a table. It dose not creates the cluster index automatically and it can have NULL value
The three different way in PHP to connect with MySQL is:
Note: We should use MySQLI because MySQLI is imporoved version of MySQL and have more function then MySQL.
By using mysql function mysqli_insert_id() we can retrive the last inserted id in database table.
By using following query we can find out the nth largest salary from employees table.
SELECT salary FROM `employees` ORDER BY salary DESC LIMIT 1 OFFSET n-1
In the above query n is replaced by any number where n >= 1. Suppose you want to find fifth highest salary then you have to use offset = 5-1 i.e.: 4
The query will be:
SELECT salary FROM `employees` ORDER BY salary DESC LIMIT 1 OFFSET 4
Most viewed posts
11 months ago 1467 views
Add number of days to a date in php
7 months ago 851 views
11 months ago 613 views
How to remove HTML tags form a string in PHP?
11 months ago 373 views
how to remove index.php in codeigniter
5 months ago 373 views
What is the use of header() function in php?
11 months ago 323 views
List Databases supported By Codeigniter Frameworks
1 month ago 54 views
In which files routes are defined in Codeigniter?
1 month ago 42 views
What is helpers in CodeIgniter and how to load helper file?
1 month ago 72 views
How to set timezone in codeigniter?
1 month ago 64 views
How to set or get config variables in Codeigniter?
1 month ago 62 views
What is the default URL pattern used in Codeigniter framework?
1 month ago 70 views
Today spacial posts