michaellunsford Posted June 11, 2006 Share Posted June 11, 2006 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 More sharing options...
michaellunsford Posted June 12, 2006 Author Share Posted June 12, 2006 figured it out three hours later:[code]INSERT INTO `options` (`value`,`option`) SELECT DISTINCT `category`,'category' FROM `links`[/code]thanks! Link to comment https://forums.phpfreaks.com/topic/11752-error-subquery-returns-more-than-1-row/#findComment-44479 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.