<?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>The Troll&#039;s factory &#187; id</title>
	<atom:link href="http://trollfactory.fr/tag/id/feed" rel="self" type="application/rss+xml" />
	<link>http://trollfactory.fr</link>
	<description>Geekeries &#38; pensées</description>
	<lastBuildDate>Mon, 09 Jun 2014 19:43:25 +0000</lastBuildDate>
	<language>fr-FR</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.41</generator>
	<item>
		<title>Connaître / récupérer le prochain ID AUTO_INCREMENT d&#8217;une table SQL</title>
		<link>http://trollfactory.fr/connaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87</link>
		<comments>http://trollfactory.fr/connaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87#comments</comments>
		<pubDate>Thu, 31 Dec 2009 22:37:21 +0000</pubDate>
		<dc:creator><![CDATA[Troll]]></dc:creator>
				<category><![CDATA[Scripts, astuces, dév. web]]></category>
		<category><![CDATA[astuce]]></category>
		<category><![CDATA[auto_increment]]></category>
		<category><![CDATA[id]]></category>
		<category><![CDATA[prochain]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://trollfactory.fr/?p=87</guid>
		<description><![CDATA[Aujourd&#8217;hui je vous fais part d&#8217;une chose que bien des gens ont cherché sur Internet et que bien des webmasters ont abandonné de trouver&#8230; la méthode pour connaître la valeur du prochain ID d&#8217;un champ de type AUTO_INCREMENT dans une table SQL. Attention cependant, cette méthode fonctionne pour une table ne comprenant qu&#8217;un seul champs [...]]]></description>
				<content:encoded><![CDATA[<p>Aujourd&rsquo;hui je vous fais part d&rsquo;une chose que bien des gens ont cherché sur Internet et que bien des webmasters ont abandonné de trouver&#8230; la méthode pour connaître la valeur du prochain ID d&rsquo;un champ de type AUTO_INCREMENT dans une table SQL.</p>
<p>Attention cependant, cette méthode fonctionne pour une table ne comprenant qu&rsquo;un seul champs de type auto_increment et pour MySQL. Je vous laisse le soin de tester (et de nous dire ce que ça donne en laissant un petit commentaire <img src="//trollfactory.fr/wp-includes/images/smilies/icon_wink.gif" alt=";-)" class="wp-smiley" /> ) et d&rsquo;adapter pour d&rsquo;autres situations, celle situation-ci restant la plus courante.</p>
<p>L&rsquo;astuce est d&rsquo;appeler la commande SHOW TABLE STATUS.</p>
<p>En effet si vous tapez par exemple cette requête SQL dans PhpMyAdmin, vous verrez apparaître plein d&rsquo;informations sur toutes les tables de votre base de données courante.</p>
<p>Si vous souhaitez réduire les lignes à une table précise :</p>
<p><code>SHOW TABLE STATUS<br />
LIKE 'NomDeLaTable'</code></p>
<p>Vous allez alors voir qu&rsquo;une colonne est nommée <em><strong>Auto_increment</strong></em> (attention à la majuscule, importante !). <strong>Cette colonne contient la prochine valeur que prendra le champs de type auto_increment de cette table. Attention : <span style="text-decoration: underline;">la PROCHAINE</span>.</strong> Si vous souhaitez connaître la dernière valeur prise par l&rsquo;auto_increment il faut donc soustraire 1. <em>Je rappelle au passage que l&rsquo;utilisation de la commande MAX() ou d&rsquo;un SELECT avec un ORDER BY DESC LIMIT 0,1 derrière ne fonctionnera pas car vous avez la possibilité que des lignes de la table aient été supprimées.</em></p>
<p>Si vous utilisez par exemple <strong>PHP</strong> et la fonction <strong>mysql_fetch_assoc()</strong> (ou <strong>mysql_fetch_array()</strong> pour les non-éclairés ou ceux qui ont besoin des clés numériques &amp; textuelles), vous récupérerez alors dans votre tableau associatif cette valeur dans la clé nommée <em><strong>&lsquo;Auto_increment&rsquo;</strong></em>.</p>
Share and Enjoy:<a rel="nofollow" target="_blank"  href="http://www.printfriendly.com/print/new?url=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/printfriendly.png" class="sociable-img sociable-hovers" title="Print" alt="Print" /></a><a rel="nofollow" target="_blank"  href="http://www.printfriendly.com/print/new?url=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/pdf.png" class="sociable-img sociable-hovers" title="PDF" alt="PDF" /></a><a rel="nofollow" target="_blank"  href="http://twitter.com/home?status=Conna%C3%AEtre%20%2F%20r%C3%A9cup%C3%A9rer%20le%20prochain%20ID%20AUTO_INCREMENT%20d%27une%20table%20SQL%20-%20http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/twitter.png" class="sociable-img sociable-hovers" title="Twitter" alt="Twitter" /></a><a rel="nofollow" target="_blank"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87&amp;t=Conna%C3%AEtre%20%2F%20r%C3%A9cup%C3%A9rer%20le%20prochain%20ID%20AUTO_INCREMENT%20d%27une%20table%20SQL" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/facebook.png" class="sociable-img sociable-hovers" title="Facebook" alt="Facebook" /></a><a rel="nofollow" target="_blank"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87&amp;title=Conna%C3%AEtre%20%2F%20r%C3%A9cup%C3%A9rer%20le%20prochain%20ID%20AUTO_INCREMENT%20d%27une%20table%20SQL&amp;source=The+Troll%26%23039%3Bs+factory+Geekeries+%26amp%3B+pens%C3%A9es&amp;summary=Aujourd%27hui%20je%20vous%20fais%20part%20d%27une%20chose%20que%20bien%20des%20gens%20ont%20cherch%C3%A9%20sur%20Internet%20et%20que%20bien%20des%20webmasters%20ont%20abandonn%C3%A9%20de%20trouver...%20la%20m%C3%A9thode%20pour%20conna%C3%AEtre%20la%20valeur%20du%20prochain%20ID%20d%27un%20champ%20de%20type%20AUTO_INCREMENT%20dans%20une%20table%20SQL.%0D%0A" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/linkedin.png" class="sociable-img sociable-hovers" title="LinkedIn" alt="LinkedIn" /></a><a rel="nofollow" target="_blank"  href="http://trollfactory.fr/feed" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/rss.png" class="sociable-img sociable-hovers" title="RSS" alt="RSS" /></a><a rel="nofollow" target="_blank"  href="http://www.wikio.fr/vote?url=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/wikio.png" class="sociable-img sociable-hovers" title="Wikio FR" alt="Wikio FR" /></a><a rel="nofollow" target="_blank"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87&amp;title=Conna%C3%AEtre%20%2F%20r%C3%A9cup%C3%A9rer%20le%20prochain%20ID%20AUTO_INCREMENT%20d%27une%20table%20SQL&amp;bodytext=Aujourd%27hui%20je%20vous%20fais%20part%20d%27une%20chose%20que%20bien%20des%20gens%20ont%20cherch%C3%A9%20sur%20Internet%20et%20que%20bien%20des%20webmasters%20ont%20abandonn%C3%A9%20de%20trouver...%20la%20m%C3%A9thode%20pour%20conna%C3%AEtre%20la%20valeur%20du%20prochain%20ID%20d%27un%20champ%20de%20type%20AUTO_INCREMENT%20dans%20une%20table%20SQL.%0D%0A" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/digg.png" class="sociable-img sociable-hovers" title="Digg" alt="Digg" /></a><a rel="nofollow" target="_blank"  href="http://delicious.com/post?url=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87&amp;title=Conna%C3%AEtre%20%2F%20r%C3%A9cup%C3%A9rer%20le%20prochain%20ID%20AUTO_INCREMENT%20d%27une%20table%20SQL&amp;notes=Aujourd%27hui%20je%20vous%20fais%20part%20d%27une%20chose%20que%20bien%20des%20gens%20ont%20cherch%C3%A9%20sur%20Internet%20et%20que%20bien%20des%20webmasters%20ont%20abandonn%C3%A9%20de%20trouver...%20la%20m%C3%A9thode%20pour%20conna%C3%AEtre%20la%20valeur%20du%20prochain%20ID%20d%27un%20champ%20de%20type%20AUTO_INCREMENT%20dans%20une%20table%20SQL.%0D%0A" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/delicious.png" class="sociable-img sociable-hovers" title="del.icio.us" alt="del.icio.us" /></a><a rel="nofollow" target="_blank"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87&amp;title=Conna%C3%AEtre%20%2F%20r%C3%A9cup%C3%A9rer%20le%20prochain%20ID%20AUTO_INCREMENT%20d%27une%20table%20SQL&amp;annotation=Aujourd%27hui%20je%20vous%20fais%20part%20d%27une%20chose%20que%20bien%20des%20gens%20ont%20cherch%C3%A9%20sur%20Internet%20et%20que%20bien%20des%20webmasters%20ont%20abandonn%C3%A9%20de%20trouver...%20la%20m%C3%A9thode%20pour%20conna%C3%AEtre%20la%20valeur%20du%20prochain%20ID%20d%27un%20champ%20de%20type%20AUTO_INCREMENT%20dans%20une%20table%20SQL.%0D%0A" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/googlebookmark.png" class="sociable-img sociable-hovers" title="Google Bookmarks" alt="Google Bookmarks" /></a><a rel="nofollow" target="_blank"  href="http://technorati.com/faves?add=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/technorati.png" class="sociable-img sociable-hovers" title="Technorati" alt="Technorati" /></a><a rel="nofollow" target="_blank"  href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/sphinn.png" class="sociable-img sociable-hovers" title="Sphinn" alt="Sphinn" /></a><a rel="nofollow" target="_blank"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87&amp;title=Conna%C3%AEtre%20%2F%20r%C3%A9cup%C3%A9rer%20le%20prochain%20ID%20AUTO_INCREMENT%20d%27une%20table%20SQL" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/mixx.png" class="sociable-img sociable-hovers" title="Mixx" alt="Mixx" /></a><a rel="nofollow" target="_blank" title="Add to favorites" href="#" onclick="AddToFavorites(); return false;"><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/addtofavorites.png" class="sociable-img sociable-hovers" title="Add to favorites" alt="Add to favorites" /></a><a rel="nofollow" target="_blank"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87&amp;title=Conna%C3%AEtre%20%2F%20r%C3%A9cup%C3%A9rer%20le%20prochain%20ID%20AUTO_INCREMENT%20d%27une%20table%20SQL" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/live.png" class="sociable-img sociable-hovers" title="Live" alt="Live" /></a><a rel="nofollow" target="_blank"  href="http://www.netvibes.com/share?title=Conna%C3%AEtre%20%2F%20r%C3%A9cup%C3%A9rer%20le%20prochain%20ID%20AUTO_INCREMENT%20d%27une%20table%20SQL&amp;url=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/netvibes.png" class="sociable-img sociable-hovers" title="Netvibes" alt="Netvibes" /></a><a rel="nofollow" target="_blank"  href="http://www.scoopeo.com/scoop/new?newurl=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87&amp;title=Conna%C3%AEtre%20%2F%20r%C3%A9cup%C3%A9rer%20le%20prochain%20ID%20AUTO_INCREMENT%20d%27une%20table%20SQL" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/scoopeo.png" class="sociable-img sociable-hovers" title="Scoopeo" alt="Scoopeo" /></a><a rel="nofollow" target="_blank"  href="http://www.viadeo.com/shareit/share/?url=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87&title=Conna%C3%AEtre%20%2F%20r%C3%A9cup%C3%A9rer%20le%20prochain%20ID%20AUTO_INCREMENT%20d%27une%20table%20SQL&urllanguage=fr" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/viadeo.png" class="sociable-img sociable-hovers" title="viadeo FR" alt="viadeo FR" /></a><a rel="nofollow" target="_blank"  href="http://identi.ca/notice/new?status_textarea=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/identica.png" class="sociable-img sociable-hovers" title="Identi.ca" alt="Identi.ca" /></a><a rel="nofollow" target="_blank"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87&amp;t=Conna%C3%AEtre%20%2F%20r%C3%A9cup%C3%A9rer%20le%20prochain%20ID%20AUTO_INCREMENT%20d%27une%20table%20SQL" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/myspace.png" class="sociable-img sociable-hovers" title="MySpace" alt="MySpace" /></a><a rel="nofollow" target="_blank"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87&amp;title=Conna%C3%AEtre%20%2F%20r%C3%A9cup%C3%A9rer%20le%20prochain%20ID%20AUTO_INCREMENT%20d%27une%20table%20SQL" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/stumbleupon.png" class="sociable-img sociable-hovers" title="StumbleUpon" alt="StumbleUpon" /></a><a rel="nofollow" target="_blank"  href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Ftrollfactory.fr%2Fconnaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87&amp;submitHeadline=Conna%C3%AEtre%20%2F%20r%C3%A9cup%C3%A9rer%20le%20prochain%20ID%20AUTO_INCREMENT%20d%27une%20table%20SQL&amp;submitSummary=Aujourd%27hui%20je%20vous%20fais%20part%20d%27une%20chose%20que%20bien%20des%20gens%20ont%20cherch%C3%A9%20sur%20Internet%20et%20que%20bien%20des%20webmasters%20ont%20abandonn%C3%A9%20de%20trouver...%20la%20m%C3%A9thode%20pour%20conna%C3%AEtre%20la%20valeur%20du%20prochain%20ID%20d%27un%20champ%20de%20type%20AUTO_INCREMENT%20dans%20une%20table%20SQL.%0D%0A&amp;submitCategory=science&amp;submitAssetType=text" ><img src="//trollfactory.fr/wp-content/plugins/sociable-30/images/default/16/yahoobuzz.png" class="sociable-img sociable-hovers" title="Yahoo! Buzz" alt="Yahoo! Buzz" /></a><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://trollfactory.fr/connaitre-recuperer-le-prochain-id-auto_increment-dune-table-sql-87/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
