0
假設的定義中使用的列名「變量」下面的查詢:其他列
select id, (select count(*) from items) as item_count,
items_stored - (select count(*) from items) from something
正如我檢查了,這是不可能重用ITEM_COUNT以下列方式:
select id, (select count(*) from items) as item_count, items_stored - item_count from something
在MySQL將打印未定義的列錯誤。
但是,我的問題是 - 是否使用下面定義的select語句 - 將使其執行兩次,從而使查詢變慢?或者它被隱藏在引擎蓋下(結果是相同的)。
(select count(*) from items)
雙重用途例如:
select id, (select count(*) from items) as item_count,
items_stored - (select count(*) from items) from something
感謝小費!雖然我仍然很好奇,如果我們像上面一樣使用相同的查詢兩次,是否會被隱藏起來。 – Josh