SET @newid=0; UPDATE tablename SET primary_key_id=(@newid:=@newid+1) ORDER BY primary_key_id; This query will reindex the primary key starts from 1
Read More »Node = Chrome V8 engine + C++
Q 1. What is Node.js? Answer: Node is runtime environment on which a javascript code can be executed. Node is built on google v8 engine. Ryan the creator of Node, integrated google chrome v8 engine with a C++ program and called it NODE. Node.js is a single-threaded but highly scalable …
Read More »Get the rank of a user in a score table
Below is Scores Table data and structure Id Name score 1 Ram 90 2 Shyam 85 3 Dhanshyam 95 4 Sita 65 5 Geeta 98 6 Radha 45 SELECT id, name, score, FIND_IN_SET( score, ( SELECT GROUP_CONCAT( score ORDER BY score DESC ) FROM scores ) ) AS rank …
Read More »How to get second-highest salary of employees in a table
Method 1) Below query can be used to find the nth maximum value, just replace 1 from nth number SELECT * FROM `emp` e1 where 1 = (select count(distinct(salary)) from emp e2 where e2.salary>e1.salary) Method 2) select * from emp where salary = (select max(salary) from emp where salary < …
Read More »Query to Re-index Primary Key of MySQL Database
SET @newid=0; UPDATE tablename SET primary_key_id=(@newid:=@newid+1) ORDER BY primary_key_id; This query will reindex the primary key starts from 1
Read More »Installing the latest MySQL 5.6 on Amazon Linux using official repos
Installing the latest MySQL 5.6 on Amazon Linux using official repos Below are the process/steps for installation: sudo yum localinstall http://repo.mysql.com/mysql-community-release-el6-3.noarch.rpm sudo yum install mysql-community-server sudo service mysqld start Configure mysqld to start on boot: sudo chkconfig mysqld on chkconfig –list mysqld And that’s it, you’re all set up and …
Read More »How to install vlc player in centos
$ cd /etc/yum.repos.d/ $ wget http://pkgrepo.linuxtech.net/el6/release/linuxtech.repo $ yum -y install vlc Step 1: Add Repository for Linuxtech – First switch user to “root” account with command “su -“ – Next run the following commands $ cd /etc/yum.repos.d/ $ wget http://pkgrepo.linuxtech.net/el6/release/linuxtech.repo Step 2: Check VLC version in Repo – Run following …
Read More »Recursively change Directory and File Permission in Linux
Change Directory Permission recursively. $ find . /var/www/html/ -type d -exec chmod 755 {} \; Change File Permission recursively. $ find . /var/www/html/ -type f -exec chmod 644 {} \;
Read More »How to Change Hostname in centos
$ vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=newHostName and: $ vi /etc/hosts 127.0.0.1 newHostName 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 and then rebooting the system
Read More »How to import mysql database using command line in linux
$ mysql -u root -p database < database_bkup.sql
Read More »