🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #6298

Re: Consulta en mysql

#6298
From: Iván Sánchez Ortega
Date: Fri, 11 Jul 2003 19:03
48 lines
2536 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

sio2 dixit:

> Evidentemente la primera parte del problema la s�:
> 
> SELECT @maximo:=MAX(campo_que_interesa) FROM tabla1;
> 
> Pero ahora no s� c�mo generar la segunda tabla a partir de la variable
> @maximo.

#!/usr/bin/php4
<?

$conn = mysql_connect("localhost","usuario","pass");

$result = mysql_query("select max(campo) as maximo from tabla");

$fila = mysql_fetch_row($result);

for ($i=0; $i< $fila['maximo']; $i++)
{
 mysql_query("insert into tabla (columna) values ($i)");
}

?>

(Suponiendo, claro, que la tabla ya est� creada)

Ojo con el alias que he usado!

- -- 
- ----------------------------------
Iv�n S�nchez Ortega -ivansanchez-arroba-escomposlinux-punto-org

http://acm.asoc.fi.upm.es/~mr/ 
Proudly running Debian Woody 3.0 Linux with 2.4.20 kernel, KDE3, and PHP4
generating this signature.
Uptime: 21:00:45 up  1:17,  1 user,  load average: 3.52, 2.16, 1.68

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE/DwnkR56dWuhgxGgRAihvAJ9J0tLG+XFItuq1/5w7pwYVg/bsrACgjBw6
V67zCggg+IcC3jkKXGL/XNs=
=3xFt
-----END PGP SIGNATURE-----
Technical Details
Message-ID: <20030711190300.47F26D.NOFFLE@BlackSpark.local>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news-lond.gip.net!skynet.be!skynet.be!213.51.129.3.MISMATCH!newshub1.home.nl!home.nl!amsnews01.chello.com!news-hub.cableinet.net!blueyonder!marmolejo.escomposlinux.org!pinsa.escomposlinux.org!not-for-mail
References: <slrnbgu024.3k6.sio2.arr@cebolleta.net.dhis.org>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f86c8,640dfadfbdbf4597
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2003-07-11 12:03:02 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news-lond.gip.net!skynet.be!skynet.be!213.51.129.3.MISMATCH!newshub1.home.nl!home.nl!amsnews01.chello.com!news-hub.cableinet.net!blueyonder!marmolejo.escomposlinux.org!pinsa.escomposlinux.org!not-for-mail
From: Iván Sánchez Ortega <ivansanchez-@rroba-escomposlinux-.punto.-org>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Consulta en mysql
Date: Fri, 11 Jul 2003 21:03:00 +0200
Organization: acm.asoc.fi.upm.es
Lines: 48
Message-ID: <20030711190300.47F26D.NOFFLE@BlackSpark.local>
References: <slrnbgu024.3k6.sio2.arr@cebolleta.net.dhis.org>
Reply-To: Iván Sánchez Ortega <ivansanchez-@rroba-escomposlinux-.punto.-org>
NNTP-Posting-Host: 80.103.143.126
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8Bit
X-Trace: pinsa.escomposlinux.org 1057950181 22827 80.103.143.126 (11 Jul 2003 19:03:01 GMT)
X-Complaints-To: newsmaster@pinsa.escomposlinux.org
NNTP-Posting-Date: Fri, 11 Jul 2003 19:03:01 +0000 (UTC)
User-Agent: KNode/0.7.6