SELECT * FROM pristabell LEFT JOIN varetabell USING(varenr) WHERE
pristabell.varenr=$item

This statement will get all prices and quantities fro a given item ($item).
Simply interate through the recordset and display the info in whatever
format you wish.

-----Original Message-----
From: Raymond Lilleødegård [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 06, 2002 11:33 AM
To: Rick Emery; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Is this possible?


My table look like this:

Pricetable: (varetabell)
--------------------
(varenr, type, pris)
VALUES
(1, '6inch', 29),
(1, '6inch meny', 51),
(1, 'footlong', 45),
(1, 'footlong meny', 66),
(1, 'salat', 39),
(1, 'salat meny', 51),
(2, '6inch', 49),
(2, '6inch meny', 69),
(2, 'footlong', 75),
(2, 'footlong meny', 96),
(2, 'salat', 49),
(2, 'salat meny', 69),


Product table: (pristabell)
-------------------
(varenr, varenavn, innhold)
VALUES
('1','Veggie Delite','Grønnsaker og ost'),
('2','Subway Club', 'Kalkun, skinke og roasbeef'),
('3','Classic Italian BMT', 'Skinke, salami og pepperoni'),



And the query that I have tried looks like this:

SELECT  varetabell.varenavn, varetabell.varenr, varetabell.innhold,
pristabell.pris  FROM varetabell, pristabell WHERE
pristabell.varenr=varetabell.varenr AND pristabell.type='6inch' AND
pristabell.type='footlong'



----- Original Message -----
From: "Rick Emery" <[EMAIL PROTECTED]>
To: "'Raymond Lilleodegard'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, February 06, 2002 6:23 PM
Subject: RE: [PHP-DB] Is this possible?


> Yes, you can do that easily.
>
> It is easier to answer your question if you show us your table structure.
>
> -----Original Message-----
> From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 06, 2002 11:16 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Is this possible?
>
>
> Hi!
>
> I have this tricky case, at lest for me : )
>
> I'm trying to get some data out of two tables and listing the data in a
> product/price site. But..... :
>
> I have one table with productinfo and one with prices.
> And it is several columns with the same id in the pricetable, because
every
> product have several sizes.
>
> So... how do I get only one row from the "product table" and two rows from
> the "price table" in one line in a page?
> Is it possible?
>
>
>
> Best regards
>
> Raymond
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to