首页 \ 问答 \ MySQL JOIN与LEFT JOIN的区别(Difference in MySQL JOIN vs LEFT JOIN)

MySQL JOIN与LEFT JOIN的区别(Difference in MySQL JOIN vs LEFT JOIN)

我有这个跨数据库查询...

SELECT
            `DM_Server`.`Jobs`.*,
            `DM_Server`.servers.Description AS server,
            digital_inventory.params,
            products.products_id,
            products.products_pdfupload,
            customers.customers_firstname,
            customers.customers_lastname
        FROM `DM_Server`.`Jobs`
        INNER JOIN `DM_Server`.servers ON servers.ServerID = Jobs.Jobs_ServerID
        JOIN `cpod_live`.`digital_inventory` ON digital_inventory.jobname = Jobs.Jobs_Name
        JOIN `cpod_live`.`products` ON products.products_pdfupload = CONCAT(digital_inventory.jobname, ".pdf")
        JOIN `cpod_live`.`customers` ON customers.customers_id = products.cID
        ORDER BY `DM_Server`.`Jobs`.Jobs_StartTime DESC LIMIT 50

它运行良好,直到我让他们LEFT JOIN 。 我以为没有指定一种类型的连接,它被认为是一个LEFT JOIN 。 不是这样吗?


I have this cross-database query...

SELECT
            `DM_Server`.`Jobs`.*,
            `DM_Server`.servers.Description AS server,
            digital_inventory.params,
            products.products_id,
            products.products_pdfupload,
            customers.customers_firstname,
            customers.customers_lastname
        FROM `DM_Server`.`Jobs`
        INNER JOIN `DM_Server`.servers ON servers.ServerID = Jobs.Jobs_ServerID
        JOIN `cpod_live`.`digital_inventory` ON digital_inventory.jobname = Jobs.Jobs_Name
        JOIN `cpod_live`.`products` ON products.products_pdfupload = CONCAT(digital_inventory.jobname, ".pdf")
        JOIN `cpod_live`.`customers` ON customers.customers_id = products.cID
        ORDER BY `DM_Server`.`Jobs`.Jobs_StartTime DESC LIMIT 50

it runs fine until I make them LEFT JOINs. I thought that by not specifying a type of join it was assumed to be a LEFT JOIN. Is this not the case?


原文:https://stackoverflow.com/questions/9770366
更新时间:2022-03-17 11:03

最满意答案

var arr=[{
    "no": "1",
    "location": "Acheh Baru",
    "postcode": "32000",
    "postOffice": "Sitiawan",
    "state": "Perak"
}, {
    "no": "2",
    "location": "Akauntan Negeri",
    "postcode": "30594",
    "postOffice": "Ipoh",
    "state": "Perak"
}, {
    "no": "3",
    "location": "Alor Kechor",
    "postcode": "32800",
    "postOffice": "Parit",
    "state": "Perak"
}];

function findObjectByKey(array, key, value) {
    for (var i = 0; i < array.length; i++) {
        if (array[i][key] === value) {
            return array[i]['location'];
        }
    }
    return null;
}

var obj = findObjectByKey(arr, 'no', "3");

console.log(obj);


var arr=[{
    "no": "1",
    "location": "Acheh Baru",
    "postcode": "32000",
    "postOffice": "Sitiawan",
    "state": "Perak"
}, {
    "no": "2",
    "location": "Akauntan Negeri",
    "postcode": "30594",
    "postOffice": "Ipoh",
    "state": "Perak"
}, {
    "no": "3",
    "location": "Alor Kechor",
    "postcode": "32800",
    "postOffice": "Parit",
    "state": "Perak"
}];

function findObjectByKey(array, key, value) {
    for (var i = 0; i < array.length; i++) {
        if (array[i][key] === value) {
            return array[i]['location'];
        }
    }
    return null;
}

var obj = findObjectByKey(arr, 'no', "3");

console.log(obj);

相关问答

更多
  • 你应该得到明显的javascript错误 var latitude = json.results[0].geometry.location.lat; var longitude = json.results[0].geometry.location.lng; 那应该是: map.setCenter(results[0].geometry.location); var latitude = results[0].geometry.location.lat(); ...
  • var arr=[{ "no": "1", "location": "Acheh Baru", "postcode": "32000", "postOffice": "Sitiawan", "state": "Perak" }, { "no": "2", "location": "Akauntan Negeri", "postcode": "30594", "postOffice": "Ipoh", "st ...
  • 我猜你只需formatted_address定JSON中的formatted_address值,所以试试这个 try { JSONObject jsonObject = new JSONObject(resultantJSONString); if (jsonObject.getString("status").equals("OK")) { ...
  • 您可能需要做的是遍历address_components数组中的结构,检查每个结构的“类型”。 当类型包含“postal_code”,然后tada,这是你的邮政编码。 类似下面的代码(对我有用):