Jump to content


Photo

Error: Subquery returns more than 1 row


  • Please log in to reply
1 reply to this topic

#1 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 11 June 2006 - 11:06 PM

This is a simple question for the right person. I'm trying to take distinct values from the `category` field in the `links` table and insert them into the `options` table. While I'm at it, I was going to also make the `option` field the term 'category'. I just can't seem to get it to work, though.

Here's the code I'm trying:
INSERT INTO `options` (`option`,`value`) VALUES ('category', (SELECT DISTINCT `category` FROM `links`))

This code works perfectly:
INSERT INTO `options` (`option`) SELECT DISTINCT `category` FROM `links`

So, how to add the `value` field as 'category' at the same time?

#2 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 12 June 2006 - 02:29 AM

figured it out three hours later:

INSERT INTO `options` (`value`,`option`) SELECT DISTINCT `category`,'category' FROM `links`

thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users