| Re: IN and NOT IN on MySQL < 4.1 |
| by McNaz on 2005/9/22 10:28:01 Quote: doesn't support subqueries. That got me too. The trick with a Not In subquery is to use a left join. So your query will become: le="color: #000000"><?php SELECT NGS_ID, NGS_Schaal FROM xoops_survey_normgroepschaal ott left join xoops_survey_normgroepschaalitem inn on ott.NRG_ID = inn.NRG_ID where inn.NRG_ID is null HTH |
| IN and NOT IN on MySQL < 4.1 |
| by Antoine on 2005/9/22 7:26:44 Hi, Currently I am about to implement a module I have been working on. This modules has been developed using MySQL 4.1. Now, however, I have to impelement it on a system that is running an earlier version of MySQL and doesn't support subqueries. Please, if anyone knows how to rewrite this query so it doesn't use subqueries I'd be most gratefull. I could solve the problem in code but that would at least quadruple the execution time. le="color: #000000"><?php SELECT NGS_ID, NGS_Schaal FROM xoops_survey_normgroepschaal, xoops_survey_normgroep WHERE NRG_ID = 7 AND xoops_survey_normgroepschaal.VRL_ID = xoops_survey_normgroep.VRL_ID AND NGS_ID NOT IN (SELECT NGS_ID FROM xoops_survey_normgroepschaalitem WHERE NRG_ID = 7) ORDER BY NGS_Schaal
|