[Python-es] Seleccionar un solo elemento SQL

Carlos Mathiasen gunmath987 en gmail.com
Lun Abr 30 21:34:10 CEST 2012


2012/4/30 Diego Uribe Gamez <diego.uribe.gamez en gmail.com>

> Gracias
>
> sql = """select * from hospital_resgitro where id_usuario='42004790'
> limit 1"""
>
> eso me da el resultado, solo se selecciona el ultimo registro ingresado
>
> De la forma que siempre hice no deberías suponer que te trae el último
registro. Sino que sólo te trae un registro según el id_usuario que le
mandaste. Para que realmente te traiga el último y estes seguro que te trae
el último deberias ordenar por algún campo, por ejemplo fecha_de_creacion:

sql = """select * from hospital_resgitro where id_usuario='42004790' limit
1 order by fecha_de_creacion DESC"""

Matt's
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://mail.python.org/pipermail/python-es/attachments/20120430/360aa349/attachment.html>


Más información sobre la lista de distribución Python-es