MySQL query to find number of employees under manager

In this tutorial I am going to show you how to find the number of employees under manager. Generally employees and managers both are employees of an organization. But according to the experience level seniority some employees in the organization become manager, lead, etc. Therefore the junior employees are going to report the senior employees. This example will show you how to find those senior employees, mainly managers, and how many junior employees are there under each manager.

Continue

MySQL procedure to split a column into rows using a delimiter

Suppose, there is a table called sometbl and has the following data into it. CREATE TABLE sometbl ( ID INT, NAME VARCHAR(50) ); INSERT INTO sometbl VALUES (1, ‘Smith’), (2, ‘Julio|Jones|Falcons’), (3, ‘White|Snow’), (4, ‘Paint|It|Red’), (5, ‘Green|Lantern’), (6, ‘Brown|bag’); Therefore for (2), example rows would look like >> “3, white”, “3, Snow” …

Continue

MySQL error – Access denied for user ‘root’@’localhost’

If you get an error message like this: Access denied for user: ‘username@localhost’ (Using password: YES) then the problem is that user can not access the database. This can have several causes: First of all, you use the correct name and password of your MySQL user for connecting to your database. Secondly, make sure the your database user has the password and it is not blank. If your database user does not have any password then create a password for your database user by following the steps below. Start the…

Continue

Prevent SQL Injection in Codeigniter

Introduction This tutorial will show you how to prevent SQL injection in Codeigniter application. It is very important to escape the variable you pass to the database query because, in web application security, SQL injections play an important role. SQL injection is: a malicious code injection technique that may destroy your database. one of the most common web hacking techniques. the placement of malicious code in SQL statements, via input fields in web page. You usually use mysql_real_escape_string() function to prevent SQL injections, but you do not need to use…

Continue

DataTable using Codeigniter, MySQL and AJAX

I will show you how we can use DataTable API 1.10 in Codeigniter framework. You may also be interested in DataTable CRUD Example using Codeigniter, MySQL and AJAX Grid view in an Web page is a very important now-a-days. Functions like sorting, searching, pagination is not an easy job in HTML tables. One of many grid view frameworks, an open source, light weight, highly flexible and customizable DataTable API is the most popular among. It offers features like AutoFill, inline editing, sticky header, responsive, and supports bootstrap. In version 1.10 DataTable…

Continue

PHP MySQL Login Logout with Remember Me

This tutorial will show you how to login to an application with remember me functionality. Sometimes you need to remember username and password for few days or years so that next time onward a user can login without entering the username and password into the input fields. The username and password fields get populated automatically from the cookie where the username and password are kept for few days or years. An http cookie is a small piece of data sent from a website and stored on the user’s computer by…

Continue

Call Stored Procedure using Spring StoredProcedure

This tutorial will show you how we can call stored procedure using Spring StoredProcedure. I assume you have a basic idea on stored procedure what it does and what are the advantages of using stored procedure. I am going to build the project using both maven and gradle build tools. Related Posts: Call Stored Procedure using Spring SimpleJdbcCall Sometimes we need to call a stored procedure while a single SQL statement is unable to fulfil our requirements because, it permits to execute multiple SQL statements and it also allows us…

Continue