我有这个 sql 查询:
SELECT *
FROM products p, products_description pd, products_to_categories c left
join products_sex ps on (c.products_id = ps.products_id),
categories cc
WHERE p.products_id = pd.products_id
and p.products_id = c.products_id
and cc.categories_id = c.categories_id
and p.products_status = 1
and p.products_price >= 15.8333333333
and p.products_price <= 40
and p.products_quantity > 0
and (ps.products_sex = "U" or ps.products_sex is null)
and (c.categories_id = 77 or cc.parent_id = 77)
ORDER BY products_sort_order, p.products_date_added desc, pd.products_name ASC
LIMIT 0, 40
如果我在 MySQL 客户端(命令行或 Navicat)执行它,我会得到以下结果:
products_id | dodavatelia_id ...
2153 | 67 ...
但是,如果我通过 PHP 脚本(使用 mysql_query 和 mysql_fetch_assoc)获取产品,我会得到:
array (
'products_id' => NULL,
'dodavatelia_id' => '67',
...
);
为什么我的 products_id 为 NULL?