Zen Cart Logo
Forums / General Questions / Help for mysql query!!

Help for mysql query!!

Locked

Views: 1,341

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
5 Jul 2009, 8:36 AM
#1
g_nencini avatar

g_nencini

Zen Follower

Join Date:
Mar 2006
Location:
Florence, Italy
Posts:
153
Plugin Contributions:
0

Help for mysql query!!

I'm trying to solve the problem showed at
http://www.zen-cart.com/forum/showthread.php?t=131048
but I need help with mysql:

I must work with two tables, (TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK and TABLE_PRODUCTS) and in both I want select records with the condition
where quantity <='" . $stock_reorder_level . "'

The two tables are related by the field products_id and I want retrieve all the records of the first table, and the records of the second table who's products_id IS NOT PRESENT in the first, and finally order with "order by products_id".

Can anybody help me? Thanks - Giovanni

p.s. - when solved this problem I'll post the complete solution.

6 Jul 2009, 11:01 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Help for mysql query!!

First
admin > config > stock > Stock Re-order level > set to your value

Next
admin > reports > Product Low Stock

13 Jul 2009, 4:32 AM
#3
g_nencini avatar

g_nencini

Zen Follower

Join Date:
Mar 2006
Location:
Florence, Italy
Posts:
153
Plugin Contributions:
0

Re: Help for mysql query!!

That's the solution I've found:

$products_query_raw = "select * from " .
TABLE_PRODUCTS . " as a " .
" left join " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK .
" as b using (products_id) where
b.quantity <='" . $stock_reorder_level . "' or
a.products_quantity <='" . $stock_reorder_level . "'
order by a.products_id, b.products_id, b.stock_id";

The complete solution is at the link above.

Giovanni