Oracle中是否存在类似于WITH关键字的MySQL

时间:2018-05-27 08:31:20

标签: mysql oracle

我目前正在尝试将一些Oracle SQL转换为MySQL,并在Oracle中遇到WITH关键字。 MySQL中是否有等效的WITH?感谢

Oracle中的

WITH示例:

with cus as (select id from tb_company where id=3)
select * from cus;

1 个答案:

答案 0 :(得分:1)

是的,自MySQL版本8.0以来有一个等价物:

var balance = 325.00;
var checkBalance = true;
var isActive = false;

//The first question
if (checkBalance) {
    // the second question
    if(isActive) {
        handleIsActive(balance);
    } else {
        console.log("Your account is no longer active.");
    }
} else {
    console.log("Thank you. Have a nice day");
}

function handleIsActive(balance) {
    if(balance > 0) {
        console.log("Your balance is " + balance.tofix(2) +"$.");
    } else if(balance === 0) {
        console.log("Your Accunt is empty");  
    } else {
        console.log("Your balance is negetive, please contant bank");
    }
    return;
}

https://dev.mysql.com/doc/refman/8.0/en/with.html