Copy link to clipboard
Copied
I have used the following code to display only the value for last seven days. it works fine in homepage(www.dealfindit.com) but in other page like category(www.dealfindit.com and click MP3 )
SELECT title, merchant, image, price, price_price, dollar_sign, click_here, listprice_text, dealexpire_text, added_text, to_shop, price_note, description, link_product, shipping_info, tax_info, other_info, deal_expire, list_price, category_items, buying_instruction, DATE_FORMAT(date_created, '%m/%d/%Y %l:%i %p') AS 'date_created_alias',DATE_FORMAT(date_created,'%W %M %d %Y') AS 'date_only'
FROM mylist
WHERE date_created > SUBDATE(NOW(), 7)
ORDER BY date_created DESCcode for category page
======================
SELECT title, merchant, image, price, price_price, dollar_sign, click_here, listprice_text, dealexpire_text, added_text, to_shop, price_note, description, link_product, shipping_info, tax_info, other_info, deal_expire, list_price, category_items, sub_category, buying_instruction, DATE_FORMAT(date_created, '%m/%d/%Y %l:%i %p') AS 'date_created_alias',DATE_FORMAT(date_created,'%W %M %d %Y') AS 'date_only'
FROM mylist
WHERE date_created > SUBDATE(NOW(), 7) AND title LIKE '%colname%' OR sub_category LIKE '%colname%' OR category_items LIKE '%colname%'
ORDER BY date_created DESC
When combining AND with OR's in your where clause, be careful of order of operations. In your case, you probably want to add parenthesis:
WHERE date_created > SUBDATE(NOW(), 7) AND (title LIKE '%colname%' OR sub_category LIKE '%colname%' OR category_items LIKE '%colname%')
Copy link to clipboard
Copied
When combining AND with OR's in your where clause, be careful of order of operations. In your case, you probably want to add parenthesis:
WHERE date_created > SUBDATE(NOW(), 7) AND (title LIKE '%colname%' OR sub_category LIKE '%colname%' OR category_items LIKE '%colname%')
Find more inspiration, events, and resources on the new Adobe Community
Explore Now