Re: Selecting several columns using DISTINCT

2002-02-04 Thread Michael Collins

At 4:46 PM +0100 2/3/02, Joseph Bueno wrote:
Michael Collins a écrit :
   I am trying to normalize some MySQL tables and need to move a few
  columns from one table to another while maintaining the relationship
   between the two.
   SELECT DISTINCT ProductID

  (SELECT
  ProductID,
  SmImage,
  ProductName,
  Description,
  LgImage
   WHERE ProductID=ProductID)
   FROM productSKU

   How do I rewrite this query to get what I am after?

Have you tried :
SELECT DISTINCT ProductID,SmImage,ProductName,Description,LgImage
   FROM productSKU ?

If all records with same ProductID have also the same values for
other selected fields it should work; otherwise, your normalization
has some problem.

Regards
--
Joseph Bueno


Unfortunately not, the Description differs. You are correct there is
a problem with normalization and that is what I am trying to fix. I
need to select the unique row based just on the ProductID column,
then move this foreign key to a record in a new table where ProductID
becomes the key. At the same time I want to import along with
ProductID a few more field values (which I can then remove from the
productSKU table).

--
Michael
__
||| Michael Collins   |||
||| Kuwago Web Services   |||  mailto:[EMAIL PROTECTED]
||| Seattle, WA, USA  |||  http://www.lassodev.com

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Selecting several columns using DISTINCT

2002-02-03 Thread Michael Collins

I am trying to normalize some MySQL tables and need to move a few 
columns from one table to another while maintaining the relationship 
between the two. I realize I cannot do a subselect, but in effect 
what I am wanting to do is to select the Distinct rows for the column 
ProductID and then select the columns from the rows that are found by 
the DISTINCT. This is the kind of query I have in mind:

SELECT DISTINCT ProductID

(SELECT
ProductID,
SmImage,
ProductName,
Description,
LgImage
WHERE ProductID=ProductID)

FROM productSKU

How do I rewrite this query to get what I am after?

-- 
Michael
__
||| Michael Collins   |||
||| Kuwago Web Services   |||  mailto:[EMAIL PROTECTED]
||| Seattle, WA, USA  |||  http://www.lassodev.com

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php