在SQL oracle中连接两个表

时间:2017-04-13 10:14:18

标签: sql oracle join

我正在尝试在oracle sql中加入两个表,但我似乎无法让它工作。下面的sql是我到目前为止所拥有的。 Cartype在车辆表中,价格在购买表中。他们共同的关键是ID。有人能告诉我什么是错的,并提供可能的解决办法吗?

SELECT cartype, price
FROM VEHICLE547896
INNER JOIN PURCHASE547896
ON ID = ID

顺便说一下,我之前已经问过这个问题,但我仍然感到困惑。

3 个答案:

答案 0 :(得分:1)

SELECT cartype, price
FROM VEHICLE547896 a
INNER JOIN PURCHASE547896 b
ON a.ID = b.ID

答案 1 :(得分:1)

您需要更好地了解表关系。

ID保存到VEHICLE547896表时,验证PURCHASE547896中的VehicleID的等效内容。

Vehicle_ID吗? ID?或类似的东西。因为PURCHASE547896中的ID肯定是购买的SELECT cartype, price FROM VEHICLE547896 AS v INNER JOIN PURCHASE547896 AS p ON v.ID = p.VehicleID ,而不是车辆。

func operationQueueWithBlockandCancel(){

    let mainQueue = OperationQueue.main

    let operationBlock1 = BlockOperation()
    let operationBlock2 = BlockOperation()
    let operationBlock3 = BlockOperation()


    operationBlock1.addExecutionBlock {
       //Any task
    }

    operationBlock2.addExecutionBlock {
       //Any task
    }


    operationBlock3.addExecutionBlock {
        //Any task
    }

    //Add dependency as required
    operationBlock3.addDependency(operationBlock2)
    operationBlock2.addDependency(operationBlock1)

    opQueue.addOperations([operationBlock2,operationBlock1,operationBlock3,], waitUntilFinished: false)

}

答案 2 :(得分:0)

如果你有同名的列,那么你还需要在它之前命名表

SELECT VEHICLE547896.cartype, PURCHASE547896.price
FROM VEHICLE547896
INNER JOIN PURCHASE547896 ON PURCHASE547896.ID = VEHICLE547896.ID