我想按價格訂購。但是,如果價格高於0
,我將從兩張不同的表格中獲得價格並比較它以獲得最低價格並打印出來。價格也可能只存在於一個數據庫中。我的代碼的粗略結構是:在這種情況下,我應該如何訂購價格
query1 = choose products
while = fetch the products details {
query2 = get the price1, order by price1
query3 = get the price2, order by price2
if statement to get the minimum price so price = minimum price
if (price>0) {
echo product result
}
}
如何根據價格訂購結果?
編輯:產品已被選中,我想獲得的產品的價格從兩個不同的價格表
爲什麼不能通過ORDER BY子句同時獲取產品和價格? –
你想在MySQL或PHP?它可以通過一個MySQL查詢完成。 –
可能是一個想法添加一個mysql標記,因爲你的問題是與mysql相關的 – gwillie