Search This Blog

Sunday, May 7, 2017

What is the difference between NOT and != operators in SQL ?

NOT (a LIKE 'foo%')
NOT ( (a,b) OVERLAPS (x,y) )
NOT (a BETWEEN x AND y)
NOT (a IS NULL)
Except for the overlaps operator above could also be written as:
a NOT LIKE 'foo%'
a NOT BETWEEN x AND y
a IS NOT NULL
In some situations it might be easier to understand to negate a complete expression rather then rewriting it to mean the opposite.

NOT can however be used with <> - but that wouldn't make much sense though: NOT (a <> b) is the same as a = b. Similarly you could use NOT to negate the equality operator NOT (a = b) is the same as a <>b

SQL JOIN Understanding and Examples on HR schema .

SQL JOIN
Joining is combine between multiple table based on related column ( primary key or foreign key )

INNER JOIN 
Inner join is the keyword is if the keyword is match in both side then it return the values other ways not return the value.

SELECT employees.first_name, departments.department_name
FROM employees
INNER JOIN departments  ON employees.department_id= departments.department_id;

LEFT JOIN
Left join is return all records from left table and keyword matching records from right table.
SELECT employees.first_name, departments.department_name
FROM employees
LEFT JOIN departments  ON employees.department_id= departments.department_id ;

RIGHT JOIN
Right join is return all records from right table and keyword matching records from left table.
SELECT employees.first_name, departments.department_name
FROM employees
RIGHT JOIN departments  ON employees.department_id= departments.department_id ;

OUTER JOIN
Outer join is return all records from both table why there keyword matching or not.
select employees.first_name, departments.department_name
from employees
FULL OUTER JOIN departments  ON employees.department_id= departments.department_id ;

SELF JOIN
Self join is regular join but this time in same table.
SELECT A.first_name, B.first_name from employees A, employees B ;

UNION ALL
Union is for combine data which is return from different table.
Select first_name from employees

UNION ALL
select departments_name from departments ;

Wednesday, April 5, 2017

A GOOGLE A DAY (06/04/17)

1. What was the English translation of the Arabic nickname that the oldest son of Saddam Hussein's gave himself?


Answer: wolf

2. In the 2011/2012 Official Rules of the NBA you will learn the definition of what term on page 21?

Answer: legal goal

3.John Waters wanted drag actor Divine's make-up to be a cross between Jayne Mansfield and a character from what 1950’s show?

Answer: The Howdy Doody Show

Monday, February 13, 2017

BlockAdblock


To break ad blockers blocking on your websites add you can use this script before close bodytag.

source : blockadblock.com

Sunday, October 23, 2016

HOW SESSION WORKS ? LOGIN AND LOGOUT UNDERSTANDING OF SESSION

Hi,
Now I am studying basic PHP coding. So trying to make a website without using Javas_script , Jquery, Ajax or any framework. So now I am facing lot of problems. But I get a major problem actually not problem it's difficult to understand to me and all of the students, that is session .  So Today I am going to share some of experience and understanding about session. I guess it will very helpful for beginners.

Login and Logout by using SESSION :

Yes I thing login and logout is the main work of a session. And yes it true. Now I am trying to make you understand how SESSION works to maintain this login and logout.  And could not give anybody to visit any page without UserName or PassWord.

Code : 
1. phpTagstart   session_start();// you are just start  session on your page. Normally it should open the        //first login check file in php .

2.  $signal="user is valid";     if(isset($_SESSION["anytext"]))
     $signal=$_SESSION["anytext"]; 
 //  Then wright this in your second line.  It means that a  //validation text which is set by you in SESSION and you push to a variable called $signal .
// this "anytext" could be anything.

3.  
if($signal=="user is valid")  {  phptegend  // And thirdly you should wright this line to check that  this text //was in this SESSION so this session page or form is valid. Some people are also called this line as //form validation.  

Wright all your php,html,java script everything in this gap  between  point 3 and point 4 .  

4. phpTagstart  }  phptegend     // Look carefully in last line (pont 3 ) we did not complete "{ " bracket.  So at the //end of the page we should use this line to close the bracket .   

  All blue code should be keep into php_tags .

( That's all. But it is not only  technich to maintain session. It's just easiest way as my opinion .)


Some Works of SESSION :

Hare are some basic works of SESSION:

1. SESSION a associative array. (It's like a global array but not global array. It's an array who can carry values from one page to another page )
    SESSION is a common space where can access from every page.

2. 
SESSION should start with this   session_start();  function declaration . After declaring one time it will continue in every page and carry value globally until session destroy. 

3. But we need to write session_start(); in every page at the upper site. I mean just after declaring 

4. We can push value form any page in session like this  $_SESSION["variable_name"] ; (no need use $) 

5. And get all value form session from every page under the session like 
 $variable = $_SESSION["variable_name"];  . But you must should see at beginning of the page should have  session_start();

6. We can also directly print any value from session like this echo "Welcome ".$_SESSION['variable_name'] ;  But make sure that this variable already pushed in the session .
THANK YOU

Use of sort function to sort a array in C++

It's a example of doing sort by using sort function in C++. We can use this function to sort
normal any numbers very easily .
#include
using namespace std;
int main()
{
    int arr[] = {1, 5, 8, 9, 6, 7, 3, 4, 2, 0};
    int n = sizeof(arr)/sizeof(arr[0]);
    sort(arr, arr+n);
    cout << "\nArray after sorting using "
         "default sort is : \n";
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    return 0;
}

Wednesday, October 19, 2016

SQL Database Joining Tutorial. Inner join, Left join, Right join, Full outer join.

Hallo All.
As a student of Database I realize that maximum student have some difficulty to understand JOINNING in SQL.. Now I am trying to make a little tutorial example to understand JOINNING. Hope you can understand what is joining and how it works. Let’s start…

Assuming you're joining on columns with no duplicates, which is a very common case:
·         An inner join of A and B gives the result of A intersect B, i.e. the inner part of a Venn diagram  intersection.
·         An outer join of A and B gives the results of A union B, i.e. the outer parts of a Venn diagram union.

Examples:

Suppose you have two tables, with a single column each, and data as follows:
A    B
-    -
1    3
2    4
3    5
4    6
Note that (1,2) are unique to A, (3,4) are common, and (5,6) are unique to B.
Inner join

The INNER JOIN keyword selects all rows from both tables as long as there is a match between the columns in both tables.
i.e. the two rows they have in common.
select * from a INNER JOIN b on a.a = b.b;
select a.*,b.*  from a,b where a.a = b.b;

a | b
--+--
3 | 3
4 | 4

Left join

The LEFT JOIN keyword returns all rows from the left table (table1), with the matching rows in the right table (table2). The result is NULL in the right side when there is no match.
A left outer join will give all rows in A, plus any common rows in B.
select * from a LEFT OUTER JOIN b on a.a = b.b;
select a.*,b.*  from a,b where a.a = b.b(+);

a |  b
--+-----
1 | null
2 | null
3 |    3
4 |    4



Right join

The RIGHT JOIN keyword returns all rows from the right table (table2), with the matching rows in the left table (table1). The result is NULL in the left side when there is no match.
 A right outer join will give all rows in B, plus any common rows in A.
select * from a RIGHT OUTER JOIN b on a.a = b.b;
select a.*,b.*  from a,b where a.a(+) = b.b;

a    |  b
-----+----
3    |  3
4    |  4
null5
null6

Full outer join

The FULL OUTER JOIN keyword returns all rows from the left table (table1) and from the right table (table2). The FULL OUTER JOIN keyword combines the result of both LEFT and RIGHT joins.
A full outer join will give you the union of A and B, i.e. all the rows in A and all the rows in B. If something in A doesn't have a corresponding datum in B, then the B portion is null, and vice versa.
select * from a FULL OUTER JOIN b on a.a = b.b;

 a   |  b
-----+-----
   1 | null
   2 | null
   3 |    3
   4 |    4
null |    6
null |    5


Create a Form Using Python for Save Data into Excel like a Database

#Download Pyhton from here https://www.python.org/downloads/  #Download Python: #Click the “Download Python 3.x.x” button (the latest versio...