alanlai Posted April 26, 2008 Share Posted April 26, 2008 I know that it is possible to do this using PHP, except that it would require making multiple queries instead of just one. How do I do this using one MySQL query? [pseudocode]select(select column1,column3 from table2 where column2 in explode(table1.columnA,',')),columnB,columnD,columnE,columnF,etc from table1 where BLAH BLAH BLAH(irrelevant)[/pseudocode] I have encountered two problems trying to do this. 1. I cannot find an explode function in MySQL. All I have been able to find from Google are suggestions to have temporary tables be created, populated, and queries extensively. This would defeat the purpose of trying to achieve good performance, so I am trying to find a better way. 2. I don't the proper way to handle multiple results from subqueries. I want them to be concatenated or something so that there will only be one result, but I don't know how to do this efficiently. Please help! Quote Link to comment Share on other sites More sharing options...
fenway Posted April 26, 2008 Share Posted April 26, 2008 1. mysql doesn't have lists... hence no explode. if you need one, it means you're thinking about sql like a programming language with arrays -- it doesn't have them. 2. one result for what purpose? 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.