lordzardeck Posted March 27, 2009 Share Posted March 27, 2009 For some reason I can't get a subquery within a select statement. My objective is to take the subjects, and put them into one field. My query is below, and any help is appreciated! SELECT item.circulationtypeid, item.itemid, item.accessionnum, item.lccn, item.dewey, item.author, item.illustrator, item.title, item.responsibility, item.edition, item.pubplace, item.publisher, item.pubdate, item.series, item.seriesnum, item.extent, item.illustrations, item.binding, item.condition, item.price, item.source, item.entrydate, (select itemsubject.itemid, itemsubject.itemsubjectid, itemsubject.subjectid FROM itemsubject RIGHT OUTER JOIN subject ON itemsubject.subjectid = subject.subjectid WHERE itemsubject.itemid = item.itemid) as subjectcolumn FROM item Quote Link to comment https://forums.phpfreaks.com/topic/151418-select-subqueries/ Share on other sites More sharing options...
fenway Posted April 1, 2009 Share Posted April 1, 2009 What error? What mysql version? Quote Link to comment https://forums.phpfreaks.com/topic/151418-select-subqueries/#findComment-798561 Share on other sites More sharing options...
lordzardeck Posted April 1, 2009 Author Share Posted April 1, 2009 I get the error: 1241 Operand should contain at least one column. When i researched on the internet, I found out it has to do with the select query, but I can't figure out exactly what. Quote Link to comment https://forums.phpfreaks.com/topic/151418-select-subqueries/#findComment-798598 Share on other sites More sharing options...
lordzardeck Posted April 1, 2009 Author Share Posted April 1, 2009 Oh, and my server version is MySql 5 Quote Link to comment https://forums.phpfreaks.com/topic/151418-select-subqueries/#findComment-798601 Share on other sites More sharing options...
fenway Posted April 1, 2009 Share Posted April 1, 2009 My guess is that you're returning more than a single row in that subquery. Quote Link to comment https://forums.phpfreaks.com/topic/151418-select-subqueries/#findComment-799007 Share on other sites More sharing options...
lordzardeck Posted April 1, 2009 Author Share Posted April 1, 2009 Yeah, that's intended. I wanted to take the returned fields, and combind them into one. Quote Link to comment https://forums.phpfreaks.com/topic/151418-select-subqueries/#findComment-799051 Share on other sites More sharing options...
fenway Posted April 2, 2009 Share Posted April 2, 2009 Yeah, that's intended. I wanted to take the returned fields, and combind them into one. Well, a subquery in the field list can only return a *single* value -- and I don't see a CONCAT(). Quote Link to comment https://forums.phpfreaks.com/topic/151418-select-subqueries/#findComment-799327 Share on other sites More sharing options...
lordzardeck Posted April 9, 2009 Author Share Posted April 9, 2009 how would you use concat for multiple rows in a subquery? Quote Link to comment https://forums.phpfreaks.com/topic/151418-select-subqueries/#findComment-805532 Share on other sites More sharing options...
fenway Posted April 14, 2009 Share Posted April 14, 2009 with Group_concat()... but I'm not sure what you're trying to accomplish. Quote Link to comment https://forums.phpfreaks.com/topic/151418-select-subqueries/#findComment-809838 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.