<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>scriptygoddess &#187; mySQL</title>
	<atom:link href="http://www.scriptygoddess.com/archives/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scriptygoddess.com</link>
	<description></description>
	<lastBuildDate>Thu, 08 Dec 2011 18:23:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>MySQL Cheatsheet</title>
		<link>http://www.scriptygoddess.com/archives/2007/03/24/mysql-cheatsheet/</link>
		<comments>http://www.scriptygoddess.com/archives/2007/03/24/mysql-cheatsheet/#comments</comments>
		<pubDate>Sat, 24 Mar 2007 19:27:36 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[mySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/03/24/mysql-cheatsheet/</guid>
		<description><![CDATA[Another mini-cheatsheet&#8230; I know this stuff, but I&#039;m always looking it up for the exact syntax. Connect to MySQL and to the database &#8211; mysql_connect $connect = mysql_connect("localhost", "mysqluser", "userpassword") or die(mysql_error()); Select the database &#8211; mysql_select_db mysql_select_db("databasename", $connect) or die(mysql_error()); Close connection &#8211; mysql_close mysql_close($connect) or die(mysql_error()); Select data from the database &#8211; mysql_query [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Another mini-cheatsheet&#8230; I know this stuff, but I&#039;m always looking it up for the exact syntax.</p>
<p>Connect to MySQL and to the database &#8211; <a href="http://us2.php.net/manual/en/function.mysql-connect.php">mysql_connect</a><br />
<code>$connect = mysql_connect("localhost", "mysqluser", "userpassword") or die(mysql_error());</code></p>
<p>Select the database &#8211; <a href="http://us2.php.net/manual/en/function.mysql-select-db.php">mysql_select_db</a><br />
<code>mysql_select_db("databasename", $connect) or die(mysql_error());</code></p>
<p>Close connection &#8211; <a href="http://us2.php.net/manual/en/function.mysql-close.php">mysql_close</a><br />
<code>mysql_close($connect) or die(mysql_error());</code></p>
<p>Select data from the database &#8211; <a href="http://us2.php.net/manual/en/function.mysql-query.php">mysql_query</a><br />
<code>$myquery = "SELECT tablefield, tablefield2 FROM tablename WHERE tablefield = '" .$variable. "' AND tablefield2 = '" .$variable2. "'";<br />
(or)<br />
$myquery  = "SELECT * FROM tablename WHERE tablefield = '" .$variable. "' AND tablefield2 = '" .$variable2. "'";<br />
$myresult = mysql_query($myquery ) or die(mysql_error());</code></p>
<p><a href="http://sqlcourse2.com/select2.html">Selecting</a>, <a href="http://sqlcourse2.com/groupby.html">Grouping</a>, and <a href="http://sqlcourse2.com/orderby.html">Ordering</a> the data<br />
<code>SELECT [ALL | DISTINCT] column1[,column2] FROM table1[,table2] [WHERE "conditions"] [GROUP BY "column-list"] [HAVING "conditions] [ORDER BY "column-list" [ASC | DESC] ]</code></p>
<p>Display Data &#8211; <a href="http://us2.php.net/manual/en/function.mysql-fetch-array.php">mysql_fetch_array</a><br />
<code>while ($row = mysql_fetch_array($myresult)) {<br />
echo $row["tablefield"] . " and " . $row["tablefield2"] . "&lt;br /&gt;";<br />
}</code></p>
<p><a href="http://sqlcourse.com/insert.html">Insert data</a><br />
<code>$query_insert = "INSERT INTO tablename(tablefield, tablefield2) VALUES('" .$variable. "', '" .$variable2. "')";<br />
$result_insert = mysql_query($query_insert) or die(mysql_error());</code></p>
<p>Insert data, multiple rows<br />
<code>$query_insert = "INSERT INTO tablename(tablefield, tablefield2) VALUES ('" .$variable. "', '" .$variable2. "'),<br />
('" .$variable. "', '" .$variable2. "'),<br />
('" .$variable. "', '" .$variable2. "')";<br />
$result_insert = mysql_query($query_insert) or die(mysql_error());</code></p>
<p>Update data<br />
<code>$query_update = "UPDATE tablename SET tablefield = '" .$variable. "', tablefield2 = '" .$variable. "' WHERE tablefield3 = '" .$variable3. "'";<br />
$result_update = mysql_query($query_update) or die(mysql_error());</code></p>
<p>Delete a row from a table<br />
<code>$query_delete = "DELETE FROM tablename WHERE tablefield = '" .$variable. "'";<br />
$result_delete = mysql_query($query_delete) or die(mysql_error());</code></p>
<p>Some good references:<br />
<a href="http://sqlcourse.com/">http://sqlcourse.com</a><br />
<a href="http://www.w3schools.com/sql/">http://www.w3schools.com/sql/</a></p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2007/03/24/mysql-cheatsheet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Getting Dates in mySQL with MIN() and MAX()</title>
		<link>http://www.scriptygoddess.com/archives/2004/06/27/getting-dates-in-mysql-with-min-and-max/</link>
		<comments>http://www.scriptygoddess.com/archives/2004/06/27/getting-dates-in-mysql-with-min-and-max/#comments</comments>
		<pubDate>Sun, 27 Jun 2004 21:02:30 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[mySQL]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2004/06/27/getting-dates-in-mysql-with-min-and-max/</guid>
		<description><![CDATA[I&#039;m working on a plugin that required getting the earliest date in the database, and also getting the oldest date in the database. I was hoping that there was a built-in function that did this &#8211; and there is. I found this helpful article on various mySQL techniques. And this is the one I was [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I&#039;m working on a plugin that required getting the earliest date in the database, and also getting the oldest date in the database. I was hoping that there was a built-in function that did this &#8211; and there is. <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I found <a href="http://www.samspublishing.com/articles/article.asp?p=29230">this helpful article on various mySQL techniques</a>. And this is the one I was going to use:</p>
<p><i>MIN() will return the earliest date, while MAX() returns the latest date.</i></p>
<p>So the mySQL statement will look something like this:<br />
<h3>SELECT MIN(<em>DateFieldName</em>) FROM <em>TableName</em></h3>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2004/06/27/getting-dates-in-mysql-with-min-and-max/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Reset autoincrement value in mysql tabl</title>
		<link>http://www.scriptygoddess.com/archives/2004/06/24/reset-autoincrement-value-in-mysql-tabl/</link>
		<comments>http://www.scriptygoddess.com/archives/2004/06/24/reset-autoincrement-value-in-mysql-tabl/#comments</comments>
		<pubDate>Fri, 25 Jun 2004 01:57:25 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[mySQL]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2004/06/24/reset-autoincrement-value-in-mysql-tabl/</guid>
		<description><![CDATA[So tired of searching for this, (I know it&#039;s simple, but for some reason I can&#039;t seem to keep it in memory. LOL!) You just deleted all the rows in a table &#8211; but when you add new rows &#8211; they&#039;re still starting where the deleted ones left off. Run this sql query to reset [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>So tired of searching for this, (I know it&#039;s simple, but for some reason I can&#039;t seem to keep it in memory. LOL!)</p>
<p>You just deleted all the rows in a table &#8211; but when you add new rows &#8211; they&#039;re still starting where the deleted ones left off.</p>
<p>Run this sql query to reset the autoincrement value:<br />
<h3>TRUNCATE TABLE <em>(TABLENAME)</em></h3>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2004/06/24/reset-autoincrement-value-in-mysql-tabl/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

