<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.brandon-rodriguez.com/index.php?action=history&amp;feed=atom&amp;title=MySQL%2FQueries</id>
	<title>MySQL/Queries - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.brandon-rodriguez.com/index.php?action=history&amp;feed=atom&amp;title=MySQL%2FQueries"/>
	<link rel="alternate" type="text/html" href="https://wiki.brandon-rodriguez.com/index.php?title=MySQL/Queries&amp;action=history"/>
	<updated>2026-05-07T14:27:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.brandon-rodriguez.com/index.php?title=MySQL/Queries&amp;diff=596&amp;oldid=prev</id>
		<title>Brodriguez: Create page</title>
		<link rel="alternate" type="text/html" href="https://wiki.brandon-rodriguez.com/index.php?title=MySQL/Queries&amp;diff=596&amp;oldid=prev"/>
		<updated>2021-03-18T16:12:32Z</updated>

		<summary type="html">&lt;p&gt;Create page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;All of the following queries need a [[ Programming/MySQL/Databases#Load a Database | table selected ]] to work.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Select ==&lt;br /&gt;
Grabs one or more records from a database table on success. If the query has no matches, then it returns nothing.&lt;br /&gt;
&lt;br /&gt;
=== Basic Select ===&lt;br /&gt;
The most basic SELECT statement, which grabs all records from a table:&lt;br /&gt;
 SELECT * FROM &amp;lt;table_name&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Ex, this query gets all data from the &amp;quot;adoption_puppies&amp;quot; table:&lt;br /&gt;
 SELECT * FROM adoption_puppies;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Selecting Column Fields ===&lt;br /&gt;
To only pull data from one or more specific table columns:&lt;br /&gt;
 SELECT &amp;lt;columns&amp;gt; FROM &amp;lt;table_name&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Ex, this query gets only &amp;quot;name&amp;quot; and &amp;quot;breed&amp;quot; data from the &amp;quot;adoption_puppies&amp;quot; table:&lt;br /&gt;
 SELECT name, breed FROM adoption_puppies;&lt;br /&gt;
&lt;br /&gt;
=== Select with Where Clause ===&lt;br /&gt;
To limit the number of records that return (using some criteria), we can add a WHERE clause:&lt;br /&gt;
 SELECT &amp;lt;columns&amp;gt; FROM &amp;lt;table_name&amp;gt; WHERE &amp;lt;where_clause&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Ex, this query gets only &amp;quot;name&amp;quot; and &amp;quot;age&amp;quot; data for all Golden Retrievers from the &amp;quot;adoption_puppies&amp;quot; table:&lt;br /&gt;
 SELECT name, age, FROM adoption_puppies WHERE breed == &amp;quot;Golden Retriever&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Insert ==&lt;br /&gt;
Creates a new record in a table.&lt;br /&gt;
&lt;br /&gt;
Note that the ordering of fields matter. That is, the ordering of the field names should match the ordering of the values for each respective field.&lt;br /&gt;
&lt;br /&gt;
 INSERT INTO &amp;lt;table_name&amp;gt; ( &amp;lt;field_1&amp;gt;, &amp;lt;field_2&amp;gt;, ..., &amp;lt;field_n&amp;gt;)&lt;br /&gt;
 VALUES ( &amp;lt;field_1_value&amp;gt;, &amp;lt;field_2_value&amp;gt;, ..., &amp;lt;field_n_value&amp;gt; );&lt;br /&gt;
&lt;br /&gt;
Ex:&lt;br /&gt;
 INSERT INTO adoption_puppies ( name, age )&lt;br /&gt;
 VALUES ( &amp;quot;Spot&amp;quot;, &amp;quot;3 Months&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Update ==&lt;br /&gt;
Updates an existing record in a table.&lt;br /&gt;
&lt;br /&gt;
 UPDATE &amp;lt;table_name&amp;gt;&lt;br /&gt;
 SET &amp;lt;updated_fields&amp;gt;&lt;br /&gt;
 WHERE &amp;lt;where_clause&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Ex:&lt;br /&gt;
 UPDATE adoption_puppies&lt;br /&gt;
 SET age = &amp;quot;6 Months&amp;quot;, name = &amp;quot;Spot&amp;quot;&lt;br /&gt;
 WHERE name = &amp;quot;Spot&amp;quot;, age = &amp;quot;3 Months&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
To update one or more fields of all records in a table, skip the WHERE clause:&lt;br /&gt;
 UPDATE adoption_puppies&lt;br /&gt;
 SET adopted = 1;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Delete ==&lt;br /&gt;
Removes one or more records in a table.&lt;br /&gt;
&lt;br /&gt;
{{ warn | Be very careful with delete queries. They cannot be undone! Consider backing up your database beforehand, if dealing with important data.  }}&lt;br /&gt;
&lt;br /&gt;
 DELETE FROM &amp;lt;table_name&amp;gt; WHERE &amp;lt;where_clause&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Ex:&lt;br /&gt;
 DELETE FROM adoption_puppies WHERE name == &amp;quot;Spot&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
To delete all records from a table, skip the where clause:&lt;br /&gt;
 DELETE FROM &amp;lt;table_name&amp;gt;;&lt;/div&gt;</summary>
		<author><name>Brodriguez</name></author>
	</entry>
</feed>