2016-10-31 187 views
-1

我有兩個表:operations與客戶端處理數據和customers與年齡數據。我想創建新表,vlookupcustomers添加新列Ageoperations,但它亙古不變的工作:VLOOKUP等效於MySQL

CREATE TABLE new_schema.total AS (
    SELECT new_schema.operations.Id_check,new_schema.operations.ID_client, new_schema.customers.Age 
    INNER JOIN Age ON new_schema.operations.ID_client=new_schema.customers.ID_client 
); 
+0

不確定這與Excel VLOOKUP函數有什麼關係。 – Barmar

+1

什麼「不起作用」?怎麼了?你期望會發生什麼? – AndySavage

回答

0

你有一些基本的語法錯誤。沒有FROM子句指定第一個表,並且INNER JOIN後面必須跟隨您加入的表,而不是列。

而你說你想要新的表格命名爲vlookup,但你創建了total

CREATE TABLE new_schema.vlookup AS (
    SELECT o.id_check, o.id_client, c.age 
    FROM new_schema.operations AS o 
    INNER JOIN new_schema.customers AS c ON o.id_client = c.id_client 
); 
+0

謝謝,這是工作! –