🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: chile.comp.programacion
Article #3306

Re: consulta mysql

#3306
From: Rickoj
Date: Fri, 08 Apr 2005 05:53
63 lines
2827 bytes
En las news:Xns9632115AD8204jmsnews@200.27.221.71, a Jos� Miguel Santib��ez
se le ocurrio
tipear:
> En el cap�tulo anterior (news:d34hfe$e77$1@news1.nivel5.cl), "Rick_oj"
> <rick_oj@[sin-esto]tutopia.com> dijo:
>
>> tengo la siguiente situacion (parecida)
>> una tabla con compras por clientes para dicho articulo
>> como puedo seleccionar que clientes no compro el articulo x,
>> existe un where not? (toy medio oxidado con bdd)
>>
>>
>
> algo as�:
>
> CREATE TABLE `master` (
>   `numero` varchar(20) NOT NULL default '0',
>   `cliente` tinytext NOT NULL,
>   `fecha` tinytext,
>   PRIMARY KEY  (`numero`),
>   KEY `numero` (`numero`)
> );
>
> INSERT INTO `master` (`numero`, `cliente`, `fechac`)
>  VALUES ('v1', 'lala', '2005-04-08'),
>         ('v2', 'lele', '2005-04-08'),
>         ('v3', 'lili', '2005-04-08'),
>         ('v4', 'lolo', '2005-04-08');
>
>
> CREATE TABLE `detalle` (
>   `numero` varchar(20) NOT NULL default '0',
>   `producto` int(11) NOT NULL default '0',
>   `cantidad` tinyint(4) NOT NULL default '1',
>   `precio` int(11) default NULL,
>   PRIMARY KEY  (`numero`,`producto`),
>   KEY `numprod` (`numero`,`producto`),
>   KEY `producto` (`producto`)
> );
>
> INSERT INTO `detalle` (`numero`, `producto`, `cantidad`, `precio`)
>  VALUES ('v1', 1, 1, 10),
>         ('v1', 2, 1, 10),
>         ('v1', 3, 1, 10),
>         ('v2', 1, 1, 10),
>         ('v3', 1, 1, 10),
>         ('v3', 2, 1, 10),
>         ('v4', 2, 1, 10),
>         ('v4', 3, 10, 100);
>
>
> SELECT cliente
> FROM master left join detalle on master.numero = detalle.numero
>      and producto=3
> where producto is null
>
> resultado:
>
> lele y lili

 con solo una tabla no se puede? si producto is not null en la tabla como
puede el select ser where is null, me quedo esa duda mirando el manual de
mysql (hace demasiado que vi sql)
Technical Details
Message-ID: <d356cj$l4q$1@news1.nivel5.cl>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!nntp-server.pubsub.com!news1.nivel5.cl!not-for-mail
References: <d34hfe$e77$1@news1.nivel5.cl> <Xns9632115AD8204jmsnews@200.27.221.71>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1593cb,9070da774c101bc6
X-Google-Attributes: gid1593cb,public
X-Google-Language: SPANISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!nntp-server.pubsub.com!news1.nivel5.cl!not-for-mail
From: "Rick_oj" <rick_oj@[sin-esto]tutopia.com>
Newsgroups: chile.comp.programacion
Subject: Re: consulta mysql
Date: Fri, 8 Apr 2005 01:53:03 -0400
Organization: Varios
Lines: 65
Message-ID: <d356cj$l4q$1@news1.nivel5.cl>
References: <d34hfe$e77$1@news1.nivel5.cl> <Xns9632115AD8204jmsnews@200.27.221.71>
NNTP-Posting-Host: pc-97-201-120-200.cm.vtr.net
X-Trace: news1.nivel5.cl 1112939731 21658 200.120.201.97 (8 Apr 2005 05:55:31 GMT)
X-Complaints-To: news@news1.nivel5.cl
NNTP-Posting-Date: Fri, 8 Apr 2005 05:55:31 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1478
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478