Category Archives: PHP

SQL FULL JOIN

SQL FULL JOIN  return rows when there is a match in one of the tables

Syntax

SELECT * FROM table_name1 FULL JOIN table_name2
ON table_name1.column_name=table_name2.column_name

MySQL Table – users

|+—-+——+
| id | name |
+—-+——+
|  1 | AAAA |
|  2 | BBBB |
|  3 | CCCC |
|  4 | DDDD |
|  5 | EEEE |
+—-+——+

MySQL Table – Orders

+—–+—–+——–+
| oid | uid | items  |
+—–+—–+——–+
|   1 |   1 | Pen    |
|   2 |   2 | Watch  |
|   3 |   3 | shoe   |
|   4 |   4 | mobile |
+—–+—–+——–+

Example

mysql> SELECT u.name,o.items FROM users as u FULL JOIN orders as o ON u.id=o.uid ;
+——+——–+
| name | items  |
+——+——–+
| AAAA | Pen    |
| BBBB | Watch  |
| CCCC | shoe   |
| DDDD | mobile |
+——+——–+
4 rows in set (0.00 sec)

SQL SELECT

The SELECT statement is used to select data from a database.

SQL SELECT Syntax

SELECT field_names FROM table_name

Field name should be seperated with comma .

If you want the data from all the fields ,then just use “ * “

MySQL Table – users

+—-+——+
| id | name |
+—-+——+
|  1 | PHP  |
|  2 | JS   |
|  3 | HTML |
|  4 | JSP  |
|  5 | ASP  |
+—-+——+

Example

mysql> select * from users;
+—-+——+
| id | name |
+—-+——+
|  1 | PHP  |
|  2 | PHP  |
|  3 | PHP  |
|  4 | PHP  |
|  5 | PHP  |
+—-+——+

mysql> select name  from users;
+——+
| name |
+——+
| PHP  |
| JS   |
| HTML |
| JSP  |
| ASP  |
+——+

MySQL

MySQL is a relational database management system (RDBMS)that runs as a server providing multi-user access to a number of databases. It is named after co-founder Michael Widenius’ daughter, My. The SQL phrase stands for Structured Query Language.
The MySQL development project has made its source code available under the terms of the GNU General Public License, as well as under a variety of proprietary agreements. MySQL was owned and sponsored by a single for-profit firm, the Swedish company MySQL AB, now owned by Oracle Corporation.
Free-software-open source projects that require a full-featured database management system often use MySQL. For commercial use, several paid editions are available, and offer additional functionality.

headers_list()

It returns a list of response headers sent

Example

<?php
setcookie(“time”,time());
header(‘Content-type: text/plain’);
echo “<pre>”;
print_r(headers_list());
?>

Output

<pre>Array
(
[0] => X-Powered-By: PHP/5.3.3-1ubuntu9.10
[1] => Set-Cookie: time=1337938449
[2] => Content-type: text/plain
)