Results 1 to 2 of 2

Thread: mysql problem

  1. #1
    Join Date
    Apr 2012
    Posts
    1

    Unanswered: mysql problem

    im looking to rewrite this, the logic is sound but using an OR operator slows the query right down

    ...))) OR (datafeed_id...

    is there any other way of writing this to avoid the OR.

    thanks


    $bansql = " AND (datafeed_id not in (select merchant_id from merchant_cat_ban_list_t where (

    websiteid=".$projectid." and

    IF(merchant_cat_ban_list_t.merchant_category_name <>'', merchant_cat_ban_list_t.merchant_category_name = products.category, (merchant_cat_ban_list_t.merchant_category_name ='' or merchant_cat_ban_list_t.merchant_category_name is null)) and

    IF(merchant_cat_ban_list_t.category_id <>'', merchant_cat_ban_list_t.category_id='".$_GET['id']."', (merchant_cat_ban_list_t.category_id ='' or merchant_cat_ban_list_t.category_id is null))


    ))) OR (datafeed_id in (select merchant_id from merchant_cat_white_list_t where (

    websiteid=".$projectid." and

    merchant_cat_white_list_t.category_id='".$_GET['id']."' and

    merchant_cat_white_list_t.merchant_category_name = products.category

    )))";

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    alternate strategy is to use a UNION, where the two SELECTs retrieve the two sides of the OR
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •