<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=SQL</id>
	<title>SQL - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=SQL"/>
	<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=SQL&amp;action=history"/>
	<updated>2026-05-09T08:08:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://aznot.com/index.php?title=SQL&amp;diff=5000&amp;oldid=prev</id>
		<title>Kenneth: /* Subqueries */</title>
		<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=SQL&amp;diff=5000&amp;oldid=prev"/>
		<updated>2018-11-28T20:57:46Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Subqueries&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Subqueries ==&lt;br /&gt;
&lt;br /&gt;
 SELECT * FROM t1 WHERE column1 = (SELECT column1 FROM t2);&lt;br /&gt;
&lt;br /&gt;
Subquery Converted to Inner Join:&lt;br /&gt;
 # Subquery:&lt;br /&gt;
 SELECT name &lt;br /&gt;
  FROM animal &lt;br /&gt;
  WHERE id &lt;br /&gt;
  IN (SELECT animal_id FROM animal_food);&lt;br /&gt;
 &lt;br /&gt;
 # Inner Join:&lt;br /&gt;
 SELECT DISTINCT name &lt;br /&gt;
  FROM animal,animal_food &lt;br /&gt;
  WHERE animal.id=animal_id;&lt;br /&gt;
&lt;br /&gt;
Subquery Converted to Outer Join:&lt;br /&gt;
 # Subquery:&lt;br /&gt;
 SELECT name FROM animal WHERE id NOT IN (SELECT animal_id FROM animal_food);&lt;br /&gt;
 &lt;br /&gt;
 # Outer Join:&lt;br /&gt;
 SELECT name FROM animal LEFT JOIN  animal_food ON animal.id=animal_id WHERE animal_id IS NULL;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
a.k.a. Inner Select&lt;br /&gt;
&lt;br /&gt;
*[http://dev.mysql.com/doc/refman/5.0/en/subqueries.html MySQL :: MySQL 5.0 Reference Manual :: 12.2.9 Subquery Syntax]&lt;br /&gt;
*[http://www.databasejournal.com/features/mysql/article.php/3434641/MySQL-Subqueries.htm MySQL Subqueries]&lt;br /&gt;
&lt;br /&gt;
== Insert ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 INSERT INTO table_name (column1, column2, column3, ...)&lt;br /&gt;
 VALUES (value1, value2, value3, ...);&lt;br /&gt;
&lt;br /&gt;
 INSERT INTO table_name&lt;br /&gt;
 VALUES (value1, value2, value3, ...);&lt;br /&gt;
&lt;br /&gt;
ref: https://www.w3schools.com/sql/sql_insert.asp&lt;br /&gt;
&lt;br /&gt;
== Replace Text ==&lt;br /&gt;
&lt;br /&gt;
 UPDATE `knowledgebase`.`kbentry` SET description=REPLACE(description, &amp;#039;/console/&amp;#039;, &amp;#039;/edit/&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
 # REPLACE(string, old_string, new_string)&lt;br /&gt;
 SELECT REPLACE(MAC, &amp;#039;-&amp;#039;, &amp;#039;:&amp;#039;) from HOSTS;&lt;br /&gt;
&lt;br /&gt;
ref: https://www.w3schools.com/sql/func_sqlserver_replace.asp&lt;/div&gt;</summary>
		<author><name>Kenneth</name></author>
	</entry>
</feed>