亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

How to execute second query when first query has no results - MYSQL
P粉998100648
P粉998100648 2023-09-16 16:12:30
0
1
1175

How to get results in MYSQL:

If the first selection has more than 0 rows, return the result, otherwise return the result of the second selection ( is not the same table , there is only one column in the two selections).

Something similar SELECT IF ((EXISTS(SELECT COLUMN 1 FROM TABLE 1)),(SELECT COLUMN 1 FROM TABLE 1),(SELECT COLUMN 1 FROM TABLE 2);

P粉998100648
P粉998100648

reply all(1)
P粉342101652

You can use the joint trick here:

WITH cte AS (
    SELECT Column1, 1 AS pos FROM Table1
    UNION ALL
    SELECT Column1, 2 FROM Table2
)

SELECT Column1
FROM cte
WHERE
    pos = 1 OR
    NOT EXISTS (SELECT 1 FROM cte WHERE pos = 1);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template