Skip to content

Commit 67e3a4d

Browse files
committed
OR -> UNION
1 parent fadb9b1 commit 67e3a4d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

isuumo/webapp/nodejs/app.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,14 @@ app.get("/api/recommended_estate/:id", async (req, res, next) => {
564564
const edges = [chair.width, chair.height, chair.depth].sort((a, b) => b - a);
565565
const w = edges[1]
566566
const h = edges[2]
567+
const sql = `
568+
SELECT * FROM (
569+
SELECT * FROM estate WHERE door_width >= ? AND door_height>= ?
570+
UNION
571+
SELECT * FROM estate WHERE door_width >= ? AND door_height>= ?
572+
) t ORDER BY popularity DESC, id ASC LIMIT ?`
567573
const es = await query(
568-
"SELECT * FROM estate where (door_width >= ? AND door_height>= ?) OR (door_width >= ? AND door_height>= ?) ORDER BY popularity DESC, id ASC LIMIT ?",
574+
sql,
569575
[w, h, h, w, LIMIT]
570576
);
571577
const estates = es.map((estate) => camelcaseKeys(estate));

0 commit comments

Comments
 (0)