Ver Mensaje Individual
  #2 (permalink)  
Antiguo 08/04/2007, 10:00
Antigol
 
Fecha de Ingreso: mayo-2003
Ubicación: Buenos Aires
Mensajes: 97
Antigüedad: 21 años
Puntos: 0
Re: Ayuda consulta sql

En la primer consulta estas juntando el campo title de la tabla titles con el campo title_id de la tabla sales, imagino que el campo title (titles) debe tener alguna descripcion, por lo tanto estarias juntando descripcion de una tabla con id de otra.

Deberia ser
select titles.title_id,title from titles,sales
where titles.title_id=sales.title_id and titles.title_id='7067'

Igualmente aunque estes empezando te recomiendo usar inner join y no tabla, tabla ya que como la usas vos estas forzando a la base muchisimo mas y con tablas de muchos registros se nota la diferencia.

select titles.title_id,title
from titles t inner join sales s
on t.title_id = s.title_id
where t.title_id='7067'


Sobre la segunda, usa between

select titles.title_id,title,price from titles where price between 20 and 30

Sino usando un and
select titles.title_id,title,price from titles where price > 20 and price < 30
__________________
Mail: Su usuario es "Admin"
Usuario : estoy poniendo "Admin" y no me lo toma.
HelpDesk : lo pone sin las comillas no???
Usuario : ah, que bol..