Skip to main content

Get Google Calendar Event List in WordPress

<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function  get_calender_events() { $params = array(); /*Get current date*/ $current_date  = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key =  "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url,

My Sql

//mysql get count of more than one field

SELECT COUNT(IF(status='Cancelled',1, NULL)) 'Cancelled',
       COUNT(IF(status='On Hold',1, NULL)) 'On Hold',
       COUNT(IF(status='Disputed',1, NULL)) 'Disputed'
FROM orders;


My Sql Join
**************

What is JOIN in MySQL?

A join enable you to retrieve records from two (or more) logically related tables in a single result set.
JOIN clauses are used to return the rows of two or more queries using two or more tables that shares a meaningful relationship based on a common set of values. These values are usually the same column name and datatype that appear in both the participating tables being joined. These columns, or possibly a single column from each table, are called the join key or common key. Mostly but not all of the time, the join key is the primary key of one table and a foreign key in another table. The join can be performed as long as the data in the columns are matching.
It can be difficult when the join involving more than two tables. It is a good practice to think of the query as a series of two table joins, when involvement of three or more tables in joins.
- See more at: http://www.w3resource.com/mysql/advance-query-in-mysql/mysql-joins.php#sthash.r5EKwMol.dpuf
 What is JOIN in MySQL?

A join enable you to retrieve records from two (or more) logically related tables in a single result set.

JOIN clauses are used to return the rows of two or more queries using two or more tables that shares a meaningful relationship based on a common set of values. These values are usually the same column name and datatype that appear in both the participating tables being joined. These columns, or possibly a single column from each table, are called the join key or common key. Mostly but not all of the time, the join key is the primary key of one table and a foreign key in another table. The join can be performed as long as the data in the columns are matching.

It can be difficult when the join involving more than two tables. It is a good practice to think of the query as a series of two table joins, when involvement of three or more tables in joins.




Types of JOIN
  • INNER JOIN
  • LEFT JOIN
  • RIGHT JOIN
  • STRAIGHT JOIN
  • CROSS JOIN
  • NATURAL JOIN
Here is the sample tables table_A and table_B, which we have used to explain the technologies behind the joins.
sample table for inner join
MySQL INNER JOIN
The INNER JOIN is such a JOIN in which all rows can be selected from both participating tables as long as there is a match between the columns. Usage of INNER JOIN combines the tables. An INNER JOIN allows rows from either table to appear in the result if and only if both tables meet the conditions specified in the ON clause.
Example
  1. SELECT * FROM table_A    
  2. INNER JOIN table_B  
  3. ON table_A.A=table_B.A;  
    inner join oupput
MySQL LEFT JOIN
The LEFT JOIN is such a join which specifies that all records be fetched from the table on the left side of the join statement. If a record returned from the left table has no matching record in the table on the right side of the join, it is still returned, and the corresponding column from the right table returns a NULL value.
Example
  1. SELECT * FROM table_A    
  2. LEFT JOIN table_B  
  3. ON table_A.A=table_B.A;  
inner join oupput
MySQL RIGHT JOIN
The RIGHT JOIN is such a join which specifies that all records be fetched from the table on the right side of the join statement, even if the table on the left has no matching record. In this case, the columns from the left table return NULL values.
Example
  1. SELECT * FROM table_A    
  2. RIGHT JOIN table_B  
  3. ON table_A.A=table_B.A;  
inner join oupput
MySQL STRAIGHT JOIN
A STRAIGHT_JOIN is such a join which scans and combines matching rows ( if specified any condition) which are stored in associated tables other wise it behaves like an INNER JOIN or JOIN of without any condition..
Example
  1. SELECT * FROM table_A    
  2. STRAIGHT JOIN table_B;  

inner join oupput
MySQL CROSS JOIN
A CROSS JOIN is such a join which specifies the complete cross product of two tables. For each record in the first table, all the records in the second table are joined, creating a potentially huge result set. This command has the same effect as leaving off the join condition, and its result set is also known as a Cartesian product.
Example

  1. SELECT * FROM table_A    
  2. CROSS JOIN table_B;  

inner join oupput
MySQL NATURAL JOIN
A NATURAL JOIN is such a join that performs the same task as an INNER or LEFT JOIN, in which the ON or USING clause refers to all columns that the tables to be joined have in common.
Example

  1. SELECT * FROM table_A    
  2. NATURAL JOIN table_B;  
inner join oupput

****************************************************************************

Get the second highest value in a MySQL table

Name    Salary
Jim       6
Foo       5
Bar       5
Steve     4

SELECT name, salary
FROM employees
WHERE salary = (SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees))

Result --> Bar 5, Foo 5
 
 or
 
/* looking for 2nd highest salary -- notice the '=2' */
SELECT name,salary FROM employees
WHERE salary = (SELECT DISTINCT(salary) FROM employees as e1
WHERE (SELECT COUNT(DISTINCT(salary))=2 FROM employees as e2
WHERE e1.salary <= e2.salary)) ORDER BY name

Result --> Bar 5, Foo 5
 
or
 
SELECT name, salary
FROM employees ORDER BY `employees`.`salary` DESC LIMIT 1 , 1
 
or
  
SELECT salary 
FROM emp 
WHERE salary = (SELECT DISTINCT(salary) 
                FROM emp as e1 
                WHERE (n) = (SELECT COUNT(DISTINCT(salary)) 
                             FROM emp as e2 
                             WHERE e1.salary <= e2.salary))
 
  

or


SELECT max(salary) FROM Employee WHERE salary NOT IN (SELECT max(salary) FROM Employee);



or

 




What is JOIN in MySQL?

A join enable you to retrieve records from two (or more) logically related tables in a single result set.
JOIN clauses are used to return the rows of two or more queries using two or more tables that shares a meaningful relationship based on a common set of values. These values are usually the same column name and datatype that appear in both the participating tables being joined. These columns, or possibly a single column from each table, are called the join key or common key. Mostly but not all of the time, the join key is the primary key of one table and a foreign key in another table. The join can be performed as long as the data in the columns are matching.
It can be difficult when the join involving more than two tables. It is a good practice to think of the query as a series of two table joins, when involvement of three or more tables in joins.
- See more at: http://www.w3resource.com/mysql/advance-query-in-mysql/mysql-joins.php#sthash.r5EKwMol

What is JOIN in MySQL?

A join enable you to retrieve records from two (or more) logically related tables in a single result set.
JOIN clauses are used to return the rows of two or more queries using two or more tables that shares a meaningful relationship based on a common set of values. These values are usually the same column name and datatype that appear in both the participating tables being joined. These columns, or possibly a single column from each table, are called the join key or common key. Mostly but not all of the time, the join key is the primary key of one table and a foreign key in another table. The join can be performed as long as the data in the columns are matching.
It can be difficult when the join involving more than two tables. It is a good practice to think of the query as a series of two table joins, when involvement of three or more tables in joins.
- See more at: http://www.w3resource.com/mysql/advance-query-in-mysql/mysql-joins.php#sthash.r5EKwMol.dp

What is JOIN in MySQL?

A join enable you to retrieve records from two (or more) logically related tables in a single result set.
JOIN clauses are used to return the rows of two or more queries using two or more tables that shares a meaningful relationship based on a common set of values. These values are usually the same column name and datatype that appear in both the participating tables being joined. These columns, or possibly a single column from each table, are called the join key or common key. Mostly but not all of the time, the join key is the primary key of one table and a foreign key in another table. The join can be performed as long as the data in the columns are matching.
It can be difficult when the join involving more than two tables. It is a good practice to think of the query as a series of two table joins, when involvement of three or more tables in joins.
- See more at: http://www.w3resource.com/mysql/advance-query-in-mysql/mysql-joins.php#sthash.r5EKwMol.dpuf

Comments

Popular posts from this blog

Create post with all post type

<?php /* add_action( 'wp_enqueue_scripts', 'mpcth_child_enqueue_scripts', 1000 ); function mpcth_child_enqueue_scripts() { wp_enqueue_style( 'mpc-styles-child', get_stylesheet_directory_uri() . '/style_custom.css' ); } */ function registration_form( $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode ) { ?>     <style>       /* Always set the map height explicitly to define the size of the div        * element that contains the map. */     #map {     height: 260px; }     </style>   <script> function initMap() {     var map = new google.maps.Map(document.getElementById('map'), {       center: {lat: -33.8688, lng: 151.2195},       zoom: 13     });     var input = document.getElementById('searchInput');    // map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);    

Create Signature pad with save on database in php

Create Signature pad with save on database in php 1.create a folder images index.php ============   <!DOCTYPE >     <head>     <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />     <title>Signature Pad</title>     <script type="text/javascript" src="jquery-1.8.0.min.js"></script>     <script type="text/javascript"> $(document).ready(function () {     /** Set Canvas Size **/     var canvasWidth = 400;     var canvasHeight = 100;     /** IE SUPPORT **/     var canvasDiv = document.getElementById('signaturePad');     canvas = document.createElement('canvas');     canvas.setAttribute('width', canvasWidth);     canvas.setAttribute('height', canvasHeight);     canvas.setAttribute('id', 'canvas');     canvasDiv.appendChild(canvas);     if (typeof G_vmlCanvasManager != 'undefined') {        

WooCommerce Mini cart With Ajax

WooCommerce Mini cart //MINI CART SECTION   <div class="productdiv rightcart">                                                         <?php if ( ! WC()->cart->is_empty() ) : ?>     <ul class="woocommerce-mini-cart cart_list product_list_widget <?php echo esc_attr( $args['list_class'] ); ?>">         <?php             do_action( 'woocommerce_before_mini_cart_contents' );             foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {                 $_product     = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );                 $product_id   = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );                 if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_widget_c