我有這樣的SQL查詢:在PHP腳本MySQL查詢將返回NULL列
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?
謝謝,這就是它。但我不明白,爲什麼它在mysql命令行工作,而在PHP中沒有。 – yetty 2013-02-09 09:54:57
@yetty>因爲SQL查詢工作正常。檢查我更新的答案 – koopajah 2013-02-09 10:00:27