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? Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.