![](/img/trans.png)
[英]How to implement oracle query to select from different tables in laravel
[英]How to select query in oracle from 2 different tables?
我創建了2個表,如下所示:
CREATE TABLE emp_bio(name VARCHAR2(15) NOT NULL ,id NUMBER, DOB DATE,PRIMARY KEY(id));
CREATE TABLE emp_sal(id NUMBER REFERENCES emp_bio(id), salary NUMBER,PRIMARY KEY(id));
現在,當我查詢為
SELECT emp_sal.salary,emp_bio.name
FROM emp_sal right join emp_bio on emp_sal.id=emp_sal;
我在輸出中得到重復的值。 誰能幫我刪除重復的值! 謝謝。
您想使用兩個表的id
列在兩個表上進行JOIN
,因為它們是與兩個表相關的:
SELECT
eb.name,
es.salary
FROM emp_bio AS eb
INNER JOIN emp_sal AS es
ON es.id = eb.id
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.