Jump to content

Error: Subquery returns more than 1 row


michaellunsford

Recommended Posts

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:
[code]INSERT INTO `options` (`option`,`value`) VALUES ('category', (SELECT DISTINCT `category` FROM `links`))[/code]

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

So, how to add the `value` field as 'category' at the same time?
Link to comment
https://forums.phpfreaks.com/topic/11752-error-subquery-returns-more-than-1-row/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.