Jump to content

Archived

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

michaellunsford

Error: Subquery returns more than 1 row

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?

Share this post


Link to post
Share on other sites
figured it out three hours later:

[code]INSERT INTO `options` (`value`,`option`) SELECT DISTINCT `category`,'category' FROM `links`[/code]

thanks!

Share this post


Link to post
Share on other sites

×

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.