Mohammad Towhidul Islam

    15-Jun-14 12:53:48 pm

    Permanent reorder MySQL table records on specific column

    create table student_tmp select id, name, phone, email from student order by name; alter table student_tmp modify column `id` int(10) primary key unsigned not null auto_increment; drop table student; alter table student_tmp rename to student; ...

    Read More


    Mohammad Towhidul Islam

    15-Jun-14 12:03:53 pm

    Alter command to change MySQL table engine, table name and column name

    Here existing engine will be changed to MyISAM ALTER TABLE student ENGINE = MyISAM; Here table students will be changed to student ALTER TABLE students RENAME TO student; Here column name will be changed to first_name ALTER TABLE student CHANGE COLUMN name first_name VARCHAR(45); ...

    Read More


    Mohammad Towhidul Islam

    15-Jun-14 11:33:55 am

    Copy an existing MySQL table data and structure

    Copy both an existing MySQL table data and structure to a new table CREATE TABLE student1 SELECT * FROM student; CREATE TABLE student2 LIKE student; CREATE TABLE IF NOT EXISTS student3 SELECT * FROM student; Copy only an existing MySQL table data to another existing table INSER...

    Read More


    Mohammad Towhidul Islam

    02-Jun-14 06:26:04 pm

    Creating "insert", "update" and "delete" triggers on table in MySQL

    In the following code you have triggers au_sales,bd_sales,ai_sales which are logs(write) into log_sales table automatically for each of every operations (insert, update, delete) on the sales table. Assuming that you have a sales table having id,employee_id, revenue, trans_on fields. sales_trig...

    Read More


    Mohammad Towhidul Islam

    31-May-14 06:55:21 pm

    Create a simple MySQL stored routine to calculate bonus

    Question: Create a MySQL stored routine to calculate bonus for the employees (sales persons) on his/her sales. Code: my_db.sql drop table if exists sales; create table sales( id int(10) primary key auto_increment, employee_id varchar(10) not null, revenue decimal(10,2) not null, trans...

    Read More


    Mir Samsuzzoha

    09-May-14 10:49:12 am

    Important mysql command

    # How to enter mysql => mysql -h localhost -u root -p Make sure that your server is switched on. # How to create database => create database databse_name; # How to delete database => drop databa...

    Read More


    Mohammad Towhidul Islam

    07-May-14 06:21:20 pm

    How to back up and restore a mysql database

    Back up From the Command Line (using mysqldump) If you have shell or telnet access to your web server, you can backup your MySQL data by using the mysqldump command. This command connects to the MySQL server and creates an SQL dump file. The dump file contains the SQL statements necessary to r...

    Read More


    Mohammad Towhidul Islam

    14-Jan-14 01:15:12 pm

    An example sql injection attack

    <?php // We didn't check $_POST['password'], it could be anything the user wanted! For example: $_POST['username'] = 'aidan'; $_POST['password'] = "' OR ''='"; // Query database to check if there are any matching u...

    Read More


    Mohammad Towhidul Islam

    17-May-13 03:16:32 pm

    Example of mysql function groupconcat php res mysqli query select id

    Example of MySQL function group_concat() <?php $res=$mysqli->query("SELECT id,GROUP_CONCAT(client_id) as clients FROM services WHERE id = 3 GROUP BY id"); $row = $res->fetch_array(MYSQLI_ASSOC); $result = $row['clients']; // $row['clients'] contains string ...

    Read More


First123Last
3 of 3 pages
Copyright © 2024. Powered by Intellect Software Ltd