Posts

Showing posts from April, 2017

Git configuration related essential command

Set user email and name after removing previous all :   git config --global --replace-all user.email "new@mail.com" git config --global --replace-all user.name "newname" Set user email and name :  git config --global --user.name "setname" git config --global --user.email "set@mail.com" Show current user email and name :  git config --global --user.name git config --global --user.email

MySQL table creation command

CREATE TABLE `std`(`id` int(11) NOT NULL AUTO_INCREMENT,`name` VARCHAR(20) DEFAULT NULL, PRIMARY KEY(`id`));

Project run on port [PHP]

Generally :  php -S localhost:8000 Laravel :  php artisan serve  [Port number will be atomically 8000] php artisan serve --port=8888 [Run on custom port]  php artisan serve --host=192.168.152.160 --port=8800  [Run on custom IP and custom port] 

MySQL-> Multiple same values from a field will be sum and the new field name will be as how I define

Question Explanation : There is a table named people and there is information stored of different people from different country. Now how we can we see how many people form Bangladesh,Canada,Italy or few others country as table view ? SELECT SUM(CASE WHEN country_name ='Bangladesh' THEN 1 ELSE 0 END) as Bangladesh, SUM(CASE WHEN country_name ='Canada' THEN 1 ELSE 0 END) as Canada from people;

MySQL Query -> get first_name and last_name from a field where is user_full_name

SELECT SUBSTRING_INDEX(user_full_name,' ',1) as first_name, SUBSTRING_INDEX(user_full_name,' ',-1) as last_name FROM users WHERE id=1;