我一共有兩張表,一張叫market_orders,另一張叫item_names。目前在下面的代碼中,我只使用 market_orders 表并做一個內部連接回到同一個表。
這段代碼的輸出現在是完美的,但是 a.item_id 是“不可讀的英語”。這就是為什么我創建了與下面使用的表具有所有相同 item_id 的表 item_names,但它還有一個名為 item_names 的列,其中包含“可讀英語”。我無法將新表 item_names 加入我已有的表中。
select a.item_id,
case when b.price > a.price then (b.price - a.price) Else 'false' END as Sellable
from market_orders a
inner join market_orders b on a.item_id = b.item_id
where a.location = 4002
and b.location = 3003
and a.enchantment_level = 3
and b.enchantment_level = 3
and a.quality_level = 1
and b.quality_level = 1
group by item_id order by sellable
uj5u.com熱心網友回復:
inner join用表添加一個item_names,并將名稱添加到select串列中。
select a.item_id, n.item_names,
case
when b.price > a.price then (b.price - a.price)
Else 'false'
END as Sellable
from market_orders a
inner join market_orders b on a.item_id = b.item_id
inner join item_names n on a.item_id = n.item_id
where a.location = 4002
and b.location = 3003
and a.enchantment_level = 3
and b.enchantment_level = 3
and a.quality_level = 1
and b.quality_level = 1
group by a.item_id order by sellable
演示
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/436644.html
上一篇:選擇具有多個地址的客戶
