Posts Tagged ‘mysql’

How to convert MySQL to MySQLi procedural methods

These are nothing but the APIs of PHP that is used to access the MySQL databases and tables. The developers can choose either one of them for their project, however, the use of MySQL extension is deprecated and will not be available in future versions. It is recommended to use the MySQLi extension with PHP 5.5 and above.

Let’s have some more information about each of them:

MySQL: This was the main extension that was designed to help PHP applications send and receive data from the MySQL database. However, the use of MySQL has been deprecated and removed as of PHP 7 and its newer versions. This is why it is not recommended for new projects, and that’s the reason why MySQLi extensions are used more nowadays.
MySQLi: The ‘i’ in MySQLi stands for Improved. Therefore, this is also known as the improved version of MySQL. It has many useful features.

  • An Object-oriented interface
  • Support for prepared statements
  • Support for multiple statements
  • Support for transactions
  • Enhanced debugging capabilities
  • Embedded server support.

Read more »

Create and grant privileges to user in MySQL

Create user in MySQL

CREATE USER 'jijokjose'@'localhost' IDENTIFIED BY 'jijokjose';


Grant all privileges to user in MySQL

GRANT ALL PRIVILEGES ON *.* TO 'jijokjose'@'localhost' WITH GRANT OPTION;


Create database in MySQL

CREATE DATABASE db_vc;


Login using CMD

mysql –user=jijokjose –password=jijokjose db_name


Import database file using CMD

H:\>mysql -u jijokjose -p db_vc < H:\\db_vc.sql
Enter password: *********


Read more »

Counting DISTINCT over multiple columns in SQL

My database contents

ID CLASS_CODE ROLL_NO NAME
1 IX 1 Jijo K Jose
2 IX 3 James Jacob
3 X 1 Joy Mathew
4 X 2 Sam George
5 IX 2 Miller John
6 X 3 Thomas John

Display values of distinct rows over one column

select distinct(ROLL_NO) from STUDENT;

ROLL_NO  
1
3
2

Read more »

Last updated by at .