It's kind hard to explain, but I'm looking for replace this with IF EXISTS to improve performance:
这很难解释,但我正在寻找用IF EXISTS替换它以提高性能:
Select ... ,
IF((SELECT COUNT( t.tab_id ) FROM tabs t WHERE t.marker_id = m.marker_id)>0,1,0) multimedia, ....
FROM markers m
WHERE ....
On this query, I would like to have a temporary column called "multimedia" filled by 1 if theres multimedia or 0 if there's not.
在这个查询中,我希望有一个名为“multimedia”的临时列,如果是多媒体则填充为1,如果没有,则填充0。
This code is executed by PHP...
这段代码由PHP执行......
1 个解决方案
#1
1
SELECT
CASE
WHEN Exists(Select 1 FROM tabs t WHERE t.marker_id = m.marker_id)
THEN 1
ELSE 0
END multimedia,
...
#1
1
SELECT
CASE
WHEN Exists(Select 1 FROM tabs t WHERE t.marker_id = m.marker_id)
THEN 1
ELSE 0
END multimedia,
...