On Sun, 2007-08-05 at 21:35 -0700, Kelvin Park wrote: > I have two tables that share product codes to relate data. > One table is called IMAGE, and another one is called the PRODUCT. > There are more than one image for every product, for example product > code 1122 will have 3 images and 4938 will have 5 images within the > IMAGE table. Since all my product information is stored in PRODUCT table > except for the image file names (e.g. 1122_1.jpg, 1122_2.jpg or > 4938_1.gif), I have to build the following query: SELECT * FROM PRODUCT, > IMAGE WHERE PRODUCT.productcode = IMAGE.productcode. However, this > causes a little problem. When I print out all the product information > with its images, more than one copy of a product is printed out (because > of multiple images for each product). I'm still looking for a way to > build a query string so that I could have only one image displayed per > product (so that a user can click on the product to view more images). > > Do you know how this problem can be best approached? You can use a group by clause to cause the result set to normalize on the grouping criteria (productcode would be a good candidate). Cheers, Rob. -- ........................................................... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ........................................................... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php