Re: mysql question
| From: | 1LT John W. Holmes | Date: | Wed, 30 Oct 2002 21:16:54 +0000 |
| Subject: | Re: mysql question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-122128@lists.php.net to get a copy of this message | ||
Yes...off topic...
Join the table with itself.
untested...
SELECT t1.shopnumber, t1.item from table t1, table t2 where t1.shopnumber =
1 and t1.shopnumber = t2.shopnumber and t1.item != t2.item
Something like that?? Play around with it...
---John Holmes...
----- Original Message -----
From: "scott" <scott@scottincz.com>
To: <php-general@lists.php.net>
Sent: Wednesday, October 30, 2002 3:43 PM
Subject: [PHP] mysql question
> Very slightly OT but great minds here
>
> I have a table with two columns and I need to get all the items that are
> not in the shop number I select, with the exception of items that are in
> the shop number I select.
>
> Table
>
> Shopnumber item
> 1 orange
> 1 banana
> 1 apple
> 1 pear
> 2 grape
> 2 coca cola
> 2 pepsi
> 3 orange
> 4 orange
> 4 pepsi
> 4 7 up
> 4 sunny delite
>
>
> I need to be able to work out all the items that are in the other shops.
> For example if a customer picks orange from shopnumber 1 I need to get a
> result that has all items in all shops except shop1
> The problem is my query still picks items that are in shop1 if they are
> in another shop as well, which is not what I need
>
> My current query is select * from table where shopnumber!=$shoprvar.
> As an example if I use select * from table where shopnumber!=1 I would
> get grape, coca-cola,pepsi (x2),7 up, sunny delite and orange (x2). I
> don't want orange because it is in shop1!!!!!
>
>
> Help and BIG THANKS for the ANSWER?
> Scott
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>