<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, ...
//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
**************
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.
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
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
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
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
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.
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
- SELECT * FROM table_A
- INNER JOIN table_B
- ON table_A.A=table_B.A;
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
- SELECT * FROM table_A
- LEFT JOIN table_B
- ON table_A.A=table_B.A;
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
- SELECT * FROM table_A
- RIGHT JOIN table_B
- ON table_A.A=table_B.A;
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
- SELECT * FROM table_A
- STRAIGHT JOIN table_B;
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
- SELECT * FROM table_A
- CROSS JOIN table_B;
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
- SELECT * FROM table_A
- NATURAL JOIN table_B;
****************************************************************************
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
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
Post a Comment