Out of curiosity, is it generally faster to do a sub query or do it in
code for something like this.
Schema of Settings table, where the PK is (ApplicationId, SettingId):
ApplicationId, SettingId, SettingValue
Select SettingValue from Settings where SettingId = 10 and
ApplicationId IN (select ApplicationId from Settings where SettingId =
22 and SettingValue = "1");
The other solution is to do the two queries separately then do the
filtering in code.
What's generally faster?
On 8/6/08, Rob Wultsch <wultsch@stripped> wrote:
> On Wed, Aug 6, 2008 at 5:18 AM, Morten Primdahl <primdahl@stripped> wrote:
>> I've tried to find out if joins are preferred over subselects, but am not
>> able to come to a definite conclusion. I read that correlated subselects
>> bad, and I should go for the join, but I know the id of the record in the
>> outer query and can hard code that into the subselect (if that makes a
> Sub queries should be avoided if possible in MySQL.
> Rob Wultsch
> wultsch (aim)
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=1