Laravel's database query builder provides a convenient, fluent interface to creating and running database queries.
- It uses PDO parameter binding to protect your application against SQL injection. There is no need to clean strings passed as bindings.


To perform a basic "inner join", you may use the join() method on a query builder instance.
The first argument is the name of the table you need to join to; the remaining arguments specify the relation of the columns for the join.
- You can join to multiple tables in a single query:
$users = DB::table('users')
 ->join('contacts', '', '=', 'contacts.user_id')
 ->join('orders', '', '=', 'orders.user_id')
 ->select('users.*', '', 'orders.price')
- To perform a "left join" query, use the leftJoin() method, in the same way as the join() method.
$users = DB::table('users')
 ->leftJoin('posts', '', '=', 'posts.user_id')


To "union" two queries together, create an initial query and use the union() method to union it with a second query.
$first = DB::table('users')->whereNull('first_name');

$users = DB::table('users')->whereNull('last_name')

- Documentation: Laravel - Database: Query Builder

Daily Test with Code Example

Which tag is used to add definition lists into a <dl> element?
<dt> <dd> <li>
  <dd> - Hyper Text Markup Language</dd>
  <dd> - Language for web pages</dd>
Which CSS property can hide an element on page, letting an empty space in its place?
display position visibility
#id {
  visibility: hidden;
Click on the event which is triggered when the mouse clicks on an object.
onclick onmouseover onfocus
document.getElementById("id").onclick = function(){
Indicate the PHP variable that contains the contents of both $_GET, $_POST, and $_COOKIE arrays.
if(isset($_REQUEST["id"])) {
  echo $_REQUEST["id"];
MySQL Database, Query Builder: Join and Union

Last accessed pages

  1. Insert, Select and Update NULL value in MySQL (22851)
  2. $_GET, $_POST and $_REQUEST Variables (25152)
  3. Check the file type before Upload (7028)
  4. Add, Change, and Remove Attributes with jQuery (33767)
  5. PHP PDO - Select query, fetch (19324)

Popular pages this month

  1. Qwop (4208)
  2. Get Attribute (ID, Class, Name, Title, Src) with jQuery (2497)
  3. Get the value of the selected /checked checkboxes in a form (1939)
  4. Drag Racer V3 (1608)
  5. Flash Games - Free online Games (1314)