<?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>Ayuda con tus Tareas &#187; Bases de Datos</title>
	<atom:link href="http://ayuda.fotopex.com/category/programacion/bases-de-datos/feed/" rel="self" type="application/rss+xml" />
	<link>http://ayuda.fotopex.com</link>
	<description>En forma fácil</description>
	<lastBuildDate>Sat, 04 Sep 2010 16:22:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1-alpha</generator>
		<item>
		<title>Solución error SQL_BIG_SELECTS</title>
		<link>http://ayuda.fotopex.com/programacion/bases-de-datos/solucion-error-sql_big_selects/</link>
		<comments>http://ayuda.fotopex.com/programacion/bases-de-datos/solucion-error-sql_big_selects/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 21:03:50 +0000</pubDate>
		<dc:creator>Mr. FotoPex</dc:creator>
				<category><![CDATA[Bases de Datos]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[SQL_BIG_SELECTS]]></category>

		<guid isPermaLink="false">http://ayuda.fotopex.com/?p=749</guid>
		<description><![CDATA[El problema viene porque estas cargando una consulta que MySqL considera que puede ser grande ó se hacen bastantes relaciones entre las tablas. The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay Ese error es debido a la variable de MySQL [...]]]></description>
			<content:encoded><![CDATA[<p>El problema viene porque estas cargando una consulta que MySqL considera que puede ser grande ó se hacen bastantes relaciones entre las tablas.</p>
<blockquote><p>The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay</p></blockquote>
<p>Ese error es debido a la variable de MySQL SQL_BIG_SELECTS, y en el mensaje mismo te indica la respuesta:</p>
<blockquote><p><strong>SELECT</strong> examinará más de <strong>MAX_JOIN_SIZE</strong> filas, revisa tu <strong>WHERE</strong> y usa <strong><em>SET SQL_BIG_SELECTS = 1</em></strong> o <strong>SET SQL_MAX_JOIN_SIZE = #</strong> si el SELECT está bien.
</p></blockquote>
<p><span id="more-749"></span></p>
<div style="padding: 5px; float: right; " >
 <script type="text/javascript"><!--
google_ad_client = "pub-6087605660472467";
/* ayuda-foto-adsense-cuadro300x250, creado 4/12/08 */ 
google_ad_slot = "1220677556";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<p>Así que antes de correr tu consulta debes indicar al MySQL que permita el uso de consultas extendidas, para eso hay que ejecutar el siguiente query con la variable <strong>SQL_BIG_SELECTS</strong>:</p>
<blockquote><p>mysql_query("set sql_big_selects=1");</p></blockquote>
<div style="clear:both;"></div>
<p>Ejemplo:</p>
<div class="igBar"><span id="lphp-2"><a href="#" onclick="javascript:showPlainTxt('php-2'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-2">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/mysql_query" target="_blank"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'SQL_BIG_SELECTS=1'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">// aquí ampliamos la consulta</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$Ssql</span> = <span style="color:#FF0000;">'SELECT .... FROM ...</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">INNER JOIN&nbsp; ...</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">INNER JOIN&nbsp; ...</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">WHERE ....</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">AND ...</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">ORDER BY ...'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$result</span> = <a href="http://www.php.net/mysql_query" target="_blank"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$Ssql</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>SQL_BIG_SELECTS = {0 | 1}</strong></p>
<p>Con valor 0, MySQL aborta los comandos SELECT que probablemente tardarán mucho tiempo (esto es, comandos para los que el optimizador estima que el número de registros examinados excede el valor de max_join_size). Esto es útil cuando un comando WHERE no aconsejable se ejecuta. El valor por defecto para una nueva conexión es 1, que permite todos los comandos SELECT .</p>
<p>Si cambia la variable de sistema max_join_size a un valor distinto a DEFAULT, SQL_BIG_SELECTS se pone a 0.</p>
]]></content:encoded>
			<wfw:commentRss>http://ayuda.fotopex.com/programacion/bases-de-datos/solucion-error-sql_big_selects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clausula LIMIT en Access, SQL, MySQL y ORACLE</title>
		<link>http://ayuda.fotopex.com/programacion/bases-de-datos/clausula-limit-en-access-sql-mysql-y-oracle/</link>
		<comments>http://ayuda.fotopex.com/programacion/bases-de-datos/clausula-limit-en-access-sql-mysql-y-oracle/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 18:53:38 +0000</pubDate>
		<dc:creator>Mr. FotoPex</dc:creator>
				<category><![CDATA[Bases de Datos]]></category>
		<category><![CDATA[Access]]></category>
		<category><![CDATA[consulta]]></category>
		<category><![CDATA[LIMIT]]></category>
		<category><![CDATA[limitar]]></category>
		<category><![CDATA[MySQL y ORACLE]]></category>
		<category><![CDATA[registros]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://ayuda.fotopex.com/?p=741</guid>
		<description><![CDATA[Para limitar el número de registros que debe devolver una consulta podemos utilizar: Para Access y MS SQL utilizaremos TOP n de esa forma obtendremos los n primeros resultados de la búsqueda, y si nos interesa son los n últimos, utilizaremos la cláusula ORDER BY Texto Plano SQL: SELECT TOP n ... FROM ... WHERE [...]]]></description>
			<content:encoded><![CDATA[<div style="padding: 5px; float: right; " >
 <script type="text/javascript"><!--
google_ad_client = "pub-6087605660472467";
/* ayuda-foto-adsense-cuadro300x250, creado 4/12/08 */ 
google_ad_slot = "1220677556";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<p>Para limitar el número de registros que debe devolver una consulta podemos utilizar:</p>
<p>Para <strong>Access</strong> y MS SQL utilizaremos <strong>TOP n</strong> de esa forma obtendremos los n primeros resultados de la búsqueda, y si nos interesa son los n últimos, utilizaremos  la cláusula <strong>ORDER BY</strong></p>
<div style="clear:both;"></div>
<div class="igBar"><span id="lsql-7"><a href="#" onclick="javascript:showPlainTxt('sql-7'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-7">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span> TOP n ... <span style="color: #993333; font-weight: bold;">FROM</span> ...</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">WHERE</span> ...</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span>... </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Para <strong>MySQL</strong> utilizaremos <strong>LIMIT n </strong>, que ademas permite el compaginado agregando al final de un <strong>SELECT</strong>la clausula "<strong>LIMIT</strong>".<br />
<strong>MySQL</strong> - <strong>LIMIT n </strong></p>
<div class="igBar"><span id="lmysql-8"><a href="#" onclick="javascript:showPlainTxt('mysql-8'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">MySQL:</span>
<div id="mysql-8">
<div class="mysql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span> ... <span style="color: #993333; font-weight: bold;">FROM</span> ...</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">WHERE</span> ...</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">LIMIT n, n </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Para ver cinco registros a partir del registro 10:</p>
<div class="igBar"><span id="lsql-9"><a href="#" onclick="javascript:showPlainTxt('sql-9'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-9">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">FROM</span> tabla <span style="color: #993333; font-weight: bold;">LIMIT</span> <span style="color: #cc66cc;color:#800000;">10</span>,<span style="color: #cc66cc;color:#800000;">5</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>ORACLE</strong> genera una variable, tal y como si fuera un campo más de cada registro de la tabla, llamada “rownum”, la cual se incrementa por cada registro que vamos recuperando. De esta manera, sólo tenemos que acceder a esta variable y controlar que no sobrepasa el número que nos hemos propuesto como límite.</p>
<div class="igBar"><span id="loracle8-10"><a href="#" onclick="javascript:showPlainTxt('oracle8-10'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">ORACLE8:</span>
<div id="oracle8-10">
<div class="oracle8">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> campos</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLE</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span> condicion</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold; text-transform: uppercase;">AND</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">ROWNUM</span> &lt;= <span style="color: #cc66cc;color:#800000;">2</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://ayuda.fotopex.com/programacion/bases-de-datos/clausula-limit-en-access-sql-mysql-y-oracle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reemplazando Cadenas en Tablas de MySQL</title>
		<link>http://ayuda.fotopex.com/programacion/bases-de-datos/reemplazando-cadenas-en-tablas-de-mysql/</link>
		<comments>http://ayuda.fotopex.com/programacion/bases-de-datos/reemplazando-cadenas-en-tablas-de-mysql/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 14:07:31 +0000</pubDate>
		<dc:creator>Mr. FotoPex</dc:creator>
				<category><![CDATA[Bases de Datos]]></category>
		<category><![CDATA[actualizar]]></category>
		<category><![CDATA[base]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://ayuda.fotopex.com/?p=646</guid>
		<description><![CDATA[Si necesitas reemplazar un mismo texto en varios registros en MySQL puedes hacerlo de la siguiente manera. Texto Plano MySQL: UPDATE la_tabla &#160;SET el_campo = &#160;REPLACE &#40;el_campo,’texto_antiguo’,texto_nuevo’&#41; Esta forma es la ideal para realizar cambios de forma masiva.]]></description>
			<content:encoded><![CDATA[<p>Si necesitas reemplazar un mismo texto en varios registros en MySQL puedes hacerlo de la siguiente manera.</p>
<div class="igBar"><span id="lmysql-12"><a href="#" onclick="javascript:showPlainTxt('mysql-12'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">MySQL:</span>
<div id="mysql-12">
<div class="mysql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">UPDATE</span> la_tabla</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #993333; font-weight: bold;">SET</span> el_campo =</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #993333; font-weight: bold;">REPLACE</span> <span style="color: #66cc66;">&#40;</span>el_campo,’texto_antiguo’,texto_nuevo’<span style="color: #66cc66;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Esta forma es la ideal para realizar cambios de forma masiva.<span id="more-646"></span></p>
<p>
 <script type="text/javascript"><!--
google_ad_client = "pub-6087605660472467";
/* ayuda-foto-adsense-cuadro300x250, creado 4/12/08 */ 
google_ad_slot = "1220677556";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://ayuda.fotopex.com/programacion/bases-de-datos/reemplazando-cadenas-en-tablas-de-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Utilizar &#8220;case when&#8221; en SQL y Access</title>
		<link>http://ayuda.fotopex.com/programacion/bases-de-datos/utilizar-case-when-en-sql-y-access/</link>
		<comments>http://ayuda.fotopex.com/programacion/bases-de-datos/utilizar-case-when-en-sql-y-access/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 02:55:20 +0000</pubDate>
		<dc:creator>Mr. FotoPex</dc:creator>
				<category><![CDATA[Bases de Datos]]></category>

		<guid isPermaLink="false">http://ayuda.fotopex.com/programacion/bases-de-datos/utilizar-case-when-en-sql-y-access/</guid>
		<description><![CDATA[Cuando tenemos una columna en una tabla de SQL que puede contener diferentes valores y según el valor queremos mostrar un texto, número, etc. Disponemos de la sentencia CASE de SQL que tiene la sintaxis: Texto Plano SQL: SELECT CASE columna &#160; WHEN valor1 THEN 'es valor 1' &#160; WHEN valor2 THEN 'es valor 2' [...]]]></description>
			<content:encoded><![CDATA[<p>Cuando tenemos una columna en una tabla de SQL que puede contener diferentes valores y según el valor queremos mostrar un texto, número, etc. Disponemos de la sentencia CASE de SQL que tiene la sintaxis:</p>
<div class="igBar"><span id="lsql-18"><a href="#" onclick="javascript:showPlainTxt('sql-18'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-18">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span> CASE columna </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; WHEN valor1 THEN <span style="color: #ff0000;">'es valor 1'</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; WHEN valor2 THEN <span style="color: #ff0000;">'es valor 2'</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; ELSE <span style="color: #ff0000;">'es valor 3'</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; END</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #993333; font-weight: bold;">FROM</span> Tabla </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Donde valor1, valor2, etc. son los valores que se encuentran almacenados en la base de datos y los textos "es valor 1", "es valor 2" Y "es valor 3" son los textos que se mostrarán en el resultado del SELECT. </p>
<p>
 <script type="text/javascript"><!--
google_ad_client = "pub-6087605660472467";
/* ayuda-foto-adsense468x60, creado 4/12/08 */
google_ad_slot = "4898031349";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
 </p>
<p>Un ejemplo de ventas anuales:<span id="more-118"></span></p>
<div class="igBar"><span id="lsql-19"><a href="#" onclick="javascript:showPlainTxt('sql-19'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-19">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span> product,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; SUM<span style="color:#006600; font-weight:bold;">&#40;</span>CASE month<span style="color:#006600; font-weight:bold;">&#40;</span>mnth<span style="color:#006600; font-weight:bold;">&#41;</span> WHEN <span style="color: #cc66cc;color:#800000;">1</span> THEN sales ELSE <span style="color: #993333; font-weight: bold;">NULL</span> END<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> jan,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; SUM<span style="color:#006600; font-weight:bold;">&#40;</span>CASE month<span style="color:#006600; font-weight:bold;">&#40;</span>mnth<span style="color:#006600; font-weight:bold;">&#41;</span> WHEN <span style="color: #cc66cc;color:#800000;">2</span> THEN sales ELSE <span style="color: #993333; font-weight: bold;">NULL</span> END<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> feb,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; SUM<span style="color:#006600; font-weight:bold;">&#40;</span>CASE month<span style="color:#006600; font-weight:bold;">&#40;</span>mnth<span style="color:#006600; font-weight:bold;">&#41;</span> WHEN <span style="color: #cc66cc;color:#800000;">3</span> THEN sales ELSE <span style="color: #993333; font-weight: bold;">NULL</span> END<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> mar,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; SUM<span style="color:#006600; font-weight:bold;">&#40;</span>CASE month<span style="color:#006600; font-weight:bold;">&#40;</span>mnth<span style="color:#006600; font-weight:bold;">&#41;</span> WHEN <span style="color: #cc66cc;color:#800000;">4</span> THEN sales ELSE <span style="color: #993333; font-weight: bold;">NULL</span> END<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> apr,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; SUM<span style="color:#006600; font-weight:bold;">&#40;</span>CASE month<span style="color:#006600; font-weight:bold;">&#40;</span>mnth<span style="color:#006600; font-weight:bold;">&#41;</span> WHEN <span style="color: #cc66cc;color:#800000;">5</span> THEN sales ELSE <span style="color: #993333; font-weight: bold;">NULL</span> END<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> may,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; SUM<span style="color:#006600; font-weight:bold;">&#40;</span>CASE month<span style="color:#006600; font-weight:bold;">&#40;</span>mnth<span style="color:#006600; font-weight:bold;">&#41;</span> WHEN <span style="color: #cc66cc;color:#800000;">6</span> THEN sales ELSE <span style="color: #993333; font-weight: bold;">NULL</span> END<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> jun,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; SUM<span style="color:#006600; font-weight:bold;">&#40;</span>CASE month<span style="color:#006600; font-weight:bold;">&#40;</span>mnth<span style="color:#006600; font-weight:bold;">&#41;</span> WHEN <span style="color: #cc66cc;color:#800000;">7</span> THEN sales ELSE <span style="color: #993333; font-weight: bold;">NULL</span> END<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> jul,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; SUM<span style="color:#006600; font-weight:bold;">&#40;</span>CASE month<span style="color:#006600; font-weight:bold;">&#40;</span>mnth<span style="color:#006600; font-weight:bold;">&#41;</span> WHEN <span style="color: #cc66cc;color:#800000;">8</span> THEN sales ELSE <span style="color: #993333; font-weight: bold;">NULL</span> END<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> aug,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; SUM<span style="color:#006600; font-weight:bold;">&#40;</span>CASE month<span style="color:#006600; font-weight:bold;">&#40;</span>mnth<span style="color:#006600; font-weight:bold;">&#41;</span> WHEN <span style="color: #cc66cc;color:#800000;">9</span> THEN sales ELSE <span style="color: #993333; font-weight: bold;">NULL</span> END<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> sep,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; SUM<span style="color:#006600; font-weight:bold;">&#40;</span>CASE month<span style="color:#006600; font-weight:bold;">&#40;</span>mnth<span style="color:#006600; font-weight:bold;">&#41;</span> WHEN <span style="color: #cc66cc;color:#800000;">10</span> THEN sales ELSE <span style="color: #993333; font-weight: bold;">NULL</span> END<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> oct,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; SUM<span style="color:#006600; font-weight:bold;">&#40;</span>CASE month<span style="color:#006600; font-weight:bold;">&#40;</span>mnth<span style="color:#006600; font-weight:bold;">&#41;</span> WHEN <span style="color: #cc66cc;color:#800000;">11</span> THEN sales ELSE <span style="color: #993333; font-weight: bold;">NULL</span> END<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> nov,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; SUM<span style="color:#006600; font-weight:bold;">&#40;</span>CASE month<span style="color:#006600; font-weight:bold;">&#40;</span>mnth<span style="color:#006600; font-weight:bold;">&#41;</span> WHEN <span style="color: #cc66cc;color:#800000;">12</span> THEN sales ELSE <span style="color: #993333; font-weight: bold;">NULL</span> END<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> dec</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">FROM</span> prodsales</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> product </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Y para ara MsAccess podemos utilizar algo asi:</p>
<p><strong>IIF(condicion, valor_si_verdad, valor_si_falso)</strong></p>
<div class="igBar"><span id="lsql-20"><a href="#" onclick="javascript:showPlainTxt('sql-20'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-20">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">cuenta,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">IIf<span style="color:#006600; font-weight:bold;">&#40;</span>columna = valor1, <span style="color: #ff0000;">'valor 1'</span>, <span style="color: #ff0000;">'valor 2'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> Valores</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">FROM</span> tabla </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Otro Ejemplo:</p>
<div class="igBar"><span id="lsql-21"><a href="#" onclick="javascript:showPlainTxt('sql-21'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-21">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span> tip_documento, Cantidad, PUnitario, Total,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">IIF<span style="color:#006600; font-weight:bold;">&#40;</span> tip_documento=<span style="color: #cc66cc;color:#800000;">1</span>, <span style="color: #ff0000;">'Entrada'</span>,<span style="color: #ff0000;">'Salida'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> Movimiento <span style="color: #993333; font-weight: bold;">FROM</span> DocumentosDetalle; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Uno mas:</p>
<div class="igBar"><span id="lsql-22"><a href="#" onclick="javascript:showPlainTxt('sql-22'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-22">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span> tip_documento,&nbsp; PUnitario, Total, Cantidad, <span style="color: #ff0000;">'Entradas'</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">FROM</span> DocumentosDetalle</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span>tip_documento<span style="color:#006600; font-weight:bold;">&#41;</span>=<span style="color: #cc66cc;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">UNION <span style="color: #993333; font-weight: bold;">ALL</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span> tip_documento,&nbsp; PUnitario, Total, Cantidad,<span style="color: #ff0000;">'Salidas'</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">FROM</span> DocumentosDetalle</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span>tip_documento<span style="color:#006600; font-weight:bold;">&#41;</span>=<span style="color: #cc66cc;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Espero que te sirvan estos detalles y muchas gracias por los comentarios que dejan, así si dan ganas de seguir escribiendo para ustedes.</p>
]]></content:encoded>
			<wfw:commentRss>http://ayuda.fotopex.com/programacion/bases-de-datos/utilizar-case-when-en-sql-y-access/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Diferencias Entre MyISAM y InnoDB</title>
		<link>http://ayuda.fotopex.com/programacion/bases-de-datos/diferencias-entre-myisam-y-innodb/</link>
		<comments>http://ayuda.fotopex.com/programacion/bases-de-datos/diferencias-entre-myisam-y-innodb/#comments</comments>
		<pubDate>Thu, 24 Jan 2008 15:28:22 +0000</pubDate>
		<dc:creator>Mr. FotoPex</dc:creator>
				<category><![CDATA[Bases de Datos]]></category>

		<guid isPermaLink="false">http://ayuda.fotopex.com/programacion/bases-de-datos/diferencias-entre-myisam-y-innodb/</guid>
		<description><![CDATA[ISAM MyISAM InnoDB DBD (Berkeley Database) El servidor de bases de datos MySQL soporta distintos tipos de tablas, como las antes mencionadas, de &#233;stas, InnoDB y MyISAM merecen una atenci&#243;n especial y mencionaremos algunas diferencias. Las tablas del tipo InnoDB est&#225;n estructuradas de forma distinta que MyISAM, ya que se almacenan en un s&#243;lo archivo [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>ISAM</li>
<li>MyISAM</li>
<li>InnoDB</li>
<li>DBD (Berkeley Database)</li>
</ul>
<p>El servidor de bases de datos MySQL soporta distintos tipos de tablas, como las antes mencionadas, de &eacute;stas, <strong>InnoDB </strong>y <strong>MyISAM </strong>merecen una atenci&oacute;n especial y mencionaremos algunas diferencias.<br />

 <script type="text/javascript"><!--
google_ad_client = "pub-6087605660472467";
/* ayuda-foto-adsense468x60, creado 4/12/08 */
google_ad_slot = "4898031349";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
 </p>
<p>Las tablas del tipo InnoDB est&aacute;n estructuradas de forma distinta que MyISAM, ya que se almacenan en un s&oacute;lo archivo en lugar de tres, y sus principales caracter&iacute;sticas son que permite trabajar con transacciones, y definir reglas de integridad referencial. </p>
<p>Las transacciones aportan una fiabilidad superior a las bases de datos. Si disponemos de una serie de consultas SQL que deben ejecutarse en conjunto, con el uso de transacciones podemos tener la certeza de que nunca nos quedaremos a medio camino de su ejecuci&oacute;n.</p>
<p>Para este fin, las tablas que soportan transacciones, como es el caso de InnoDB, son mucho m&aacute;s seguras y f&aacute;ciles de recuperar si se produce alg&uacute;n fallo en el servidor, ya que las consultas se ejecutan o no en su totalidad. Por otra parte, las transacciones pueden hacer que las consultas tarden m&aacute;s tiempo en ejecutarse.</p>
<p>Por ejemplo:</p>
<p>Al ejecutar sentencias de modificaci&oacute;n de datos SQL en MyISAM, y se produce alg&uacute;n corte en la conexi&oacute;n y las consultas no se han ejecutado completamente, puede que queden s&oacute;lo parte de los registros actualizados y no sabremos qu&eacute; registros no se han actualizado.</p>
<p>En cambio, utilizando InnoDB, si se produce un corte mientras se ejecuta la consulta SQL no se aplicar&aacute;n los cambios y podremos volver a ejecutarla, es decir, garantiza que una transacci&oacute;n se ejecute &iacute;ntegramente, de lo contrario la anula.</p>
<p>MyISAM no permite integridad referencial (uso de claves for&aacute;neas para &ldquo;enlazar&rdquo; varias tablas), en cambio InnoDB s&iacute; permite este tipo de relaciones.</p>
<p>InnoDB es m&aacute;s eficiente que MyISAM en cuanto a tiempos de respuesta para operaciones habituales, tales como INSERT, UPDATE, etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://ayuda.fotopex.com/programacion/bases-de-datos/diferencias-entre-myisam-y-innodb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inyección de código SQL</title>
		<link>http://ayuda.fotopex.com/programacion/bases-de-datos/inyeccion-de-codigo-sql/</link>
		<comments>http://ayuda.fotopex.com/programacion/bases-de-datos/inyeccion-de-codigo-sql/#comments</comments>
		<pubDate>Fri, 04 Jan 2008 17:30:01 +0000</pubDate>
		<dc:creator>Mr. FotoPex</dc:creator>
				<category><![CDATA[Bases de Datos]]></category>

		<guid isPermaLink="false">http://ayuda.fotopex.com/programacion/bases-de-datos/inyeccion-de-codigo-sql/</guid>
		<description><![CDATA[Ya vimos como evitar la inyección de código SQL de una forma simple. La inyección de código SQL consiste en la modificación del comportamiento de nuestras consultas mediante la introducción de parámetros no deseados en los campos a los que tiene acceso el usuario. Este tipo de errores puede permitir a usuarios malintencionados acceder a [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://ayuda.fotopex.com/wp-content/uploads/2008/01/ms_sql_logo.gif" width="280" height="137" alt="ms_sql_logo.gif" class="imageframe imgalignleft" />Ya vimos como <a href="http://ayuda.fotopex.com/programacion/net/login-en-vbnet-y-ms-access/">evitar la inyección de código SQL</a> de una forma simple.<br />
La inyección de código SQL consiste en la modificación del comportamiento de nuestras consultas mediante la introducción de parámetros no deseados en los campos a los que tiene acceso el usuario.</p>
<div style="clear:both;"></div>
<p>Este tipo de errores puede permitir a usuarios malintencionados acceder a datos a los que de otro modo no tendrían acceso y, en el peor de los casos, modificar el comportamiento de nuestras aplicaciones.</p>
<p>Este ejemplo esta basado en el post de <a href="http://sql.manivesa.com/Tutoriales+SQL/Programacion+.NET/150.aspx" target="_blank">Cesar Manivesa</a>.<br />

 <script type="text/javascript"><!--
google_ad_client = "pub-6087605660472467";
/* ayuda-foto-adsense468x60, creado 4/12/08 */
google_ad_slot = "4898031349";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
 <br />
Supongamos que tenemos una consulta de la siguiente forma:</p>
<div class="igBar"><span id="lvbnet-25"><a href="#" onclick="javascript:showPlainTxt('vbnet-25'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">VB.NET:</span>
<div id="vbnet-25">
<div class="vbnet">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">Dim</span> sql <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> = <span style="color: #808080;">"Select estatus From usuarios Where "</span> &amp; _</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #808080;">" usuario = '"</span> &amp; <span style="color: #0600FF;">Trim</span><span style="color: #000000;">&#40;</span><span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">txtUser</span>.<span style="color: #0000FF;">Text</span><span style="color: #000000;">&#41;</span> &amp; _</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #808080;">"' And password = '"</span> &amp; <span style="color: #0600FF;">Trim</span><span style="color: #000000;">&#40;</span><span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">txtPassword</span>.<span style="color: #0000FF;">Text</span><span style="color: #000000;">&#41;</span> &amp; <span style="color: #808080;">"'"</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>El formulario se mostraría de la siguiente forma:</p>
<p><img src="http://ayuda.fotopex.com/wp-content/uploads/2008/01/login-net-6.JPG" width="326" height="179" alt="login-net-6.JPG" class="imageframe" /></p>
<p>Ingresando nuestros datos de forma normal nuestra instrucción seria así:</p>
<blockquote><p>Select estatus From usuarios Where usuario = 'kike' And password = 'prueba'</p></blockquote>
<p>Pero ingresando en la caja de texto <strong>password</strong> este código: <strong>prueba' or usuario<>'1</strong>, la instrucción quedaría así:</p>
<blockquote><p>Select estatus From usuarios Where usuario = 'kike' And password = 'prueba' or usuario<>'1'</p></blockquote>
<p>Obviamente al ser ejecutada nos devuelve registros y obtendríamos acceso al programa.</p>
<p>Y ahora lo más importante, ¿qué podemos hacer para evitar estos errores?<br />
Pues hay varios sistemas para evitarlo. Por ejemplo podemos filtrar las entradas de los usuarios reemplazando la aparición de <strong>'</strong>(comillas simples) por otro carácter e incluso evitando que los usuarios puedan pasar caracteres como \ / “ ‘ o cualquier otro que se nos ocurra que puede causar problemas. Estos filtros pueden ser tan sencillos como utilizar la sentencia <strong>Replace</strong> de Visual Basic:</p>
<div class="igBar"><span id="lvbnet-26"><a href="#" onclick="javascript:showPlainTxt('vbnet-26'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">VB.NET:</span>
<div id="vbnet-26">
<div class="vbnet">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">Dim</span> sql <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> = <span style="color: #808080;">"Select estatus From usuarios Where "</span> &amp; _</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #808080;">" usuario = '"</span> &amp; <span style="color: #0600FF;">Trim</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">txtUser</span>.<span style="color: #0000FF;">Text</span>, <span style="color: #808080;">"'"</span>, <span style="color: #808080;">"k"</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> &amp; _</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #808080;">"' And password&nbsp; = '"</span> &amp; <span style="color: #0600FF;">Trim</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">txtPassword</span>.<span style="color: #0000FF;">Text</span>, <span style="color: #808080;">"'"</span>, <span style="color: #808080;">"k"</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> &amp; <span style="color: #808080;">"'"</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Entonces nuestra sentencia alterada quedaría así:</p>
<blockquote><p>Select estatus From usuarios Where usuario = 'kike' And password = 'pruebak or usuario<>k1'</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ayuda.fotopex.com/programacion/bases-de-datos/inyeccion-de-codigo-sql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Concatenar Campos en MySQL</title>
		<link>http://ayuda.fotopex.com/programacion/bases-de-datos/concatenar-campos-en-mysql/</link>
		<comments>http://ayuda.fotopex.com/programacion/bases-de-datos/concatenar-campos-en-mysql/#comments</comments>
		<pubDate>Fri, 04 Jan 2008 17:29:47 +0000</pubDate>
		<dc:creator>Mr. FotoPex</dc:creator>
				<category><![CDATA[Bases de Datos]]></category>

		<guid isPermaLink="false">http://ayuda.fotopex.com/programacion/bases-de-datos/concatenar-campos-en-mysql/</guid>
		<description><![CDATA[La función CONCAT de MySQL permite concatenar campos como uno solo. Por ejemplo: Texto Plano MySQL: SELECT CONCAT&#40;YEAR&#40;fecha_inicio&#41;,'-', YEAR&#40;fecha_final&#41;&#41; as Ciclo FROM tabla ; Lo que nos dará: 2001-2005]]></description>
			<content:encoded><![CDATA[<div style="padding: 5px; float: left; " >
 <script type="text/javascript"><!--
google_ad_client = "pub-6087605660472467";
/* ayuda-foto-adsense-cuadro300x250, creado 4/12/08 */ 
google_ad_slot = "1220677556";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<p>La función CONCAT de MySQL permite concatenar campos como uno solo.<br />
Por ejemplo:</p>
<div style="clear:both;"></div>
<div class="igBar"><span id="lmysql-28"><a href="#" onclick="javascript:showPlainTxt('mysql-28'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">MySQL:</span>
<div id="mysql-28">
<div class="mysql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">CONCAT</span><span style="color: #66cc66;">&#40;</span><span style="color: #aa9933; font-weight: bold;">YEAR</span><span style="color: #66cc66;">&#40;</span>fecha_inicio<span style="color: #66cc66;">&#41;</span>,<span style="color: #ff0000;">'-'</span>, <span style="color: #aa9933; font-weight: bold;">YEAR</span><span style="color: #66cc66;">&#40;</span>fecha_final<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> as Ciclo <span style="color: #993333; font-weight: bold;">FROM</span> tabla ; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Lo que nos dará:<br />
<strong>2001-2005</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://ayuda.fotopex.com/programacion/bases-de-datos/concatenar-campos-en-mysql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
