我試圖找到凡人有一定的地址。SQL查找地址?
我有我認爲是正確的代碼,但無論我對'WHERE'子句做什麼,都得不到返回的結果。
的人S.
住在雅法4389臺創建的姓和名的唯一列表我已經試過
SELECT MORTAL.FIRST_NAME||' '||MORTAL.LAST_NAME "4389_Jaffa_Terrace_S"
FROM MORTAL
JOIN MORTAL_ADDRESS ON MORTAL.MORTAL_ID = MORTAL_ADDRESS.MORTAL_ID
JOIN ADDRESS ON MORTAL_ADDRESS.ADDRESS_ID = ADDRESS.ADDRESS_ID
WHERE ADDRESS.ADDRESS_LINE1 LIKE '%4389%';
SELECT FIRST_NAME||' '||LAST_NAME "4389_Jaffa_Terrace_S"
FROM MORTAL
JOIN MORTAL_ADDRESS ON MORTAL.MORTAL_ID = MORTAL_ADDRESS.MORTAL_ID
JOIN ADDRESS ON MORTAL_ADDRESS.ADDRESS_ID = ADDRESS.ADDRESS_ID:
WHERE ADDRESS.ADDRESS_LINE1 LIKE '%4389%';
SQL> SELECT FIRST_NAME||' '||LAST_NAME "4389_Jaffa_Terrace_S"
2 FROM MORTAL
3 JOIN MORTAL_ADDRESS ON MORTAL.MORTAL_ID = MORTAL_ADDRESS.MORTAL_ID
4 JOIN ADDRESS ON MORTAL_ADDRESS.ADDRESS_ID = ADDRESS.ADDRESS_ID
5 WHERE UPPER(ADDRESS.ADDRESS_LINE1) LIKE '%4389%';
no rows selected
SQL> SELECT FIRST_NAME||' '||LAST_NAME "4389_Jaffa_Terrace_S"
2 FROM MORTAL
3 JOIN MORTAL_ADDRESS ON MORTAL.MORTAL_ID = MORTAL_ADDRESS.MORTAL_ID
4 JOIN ADDRESS ON MORTAL_ADDRESS.ADDRESS_ID = ADDRESS.ADDRESS_ID
5 WHERE UPPER(ADDRESS.ADDRESS_LINE1) LIKE '%JAFFA%';
SQL> SELECT FIRST_NAME||' '||LAST_NAME "4389_Jaffa_Terrace_S"
2 FROM MORTAL
3 JOIN MORTAL_ADDRESS ON MORTAL.MORTAL_ID = MORTAL_ADDRESS.MORTAL_ID
4 JOIN ADDRESS ON MORTAL_ADDRESS.ADDRESS_ID = ADDRESS.ADDRESS_ID
5 WHERE SUBSTR(ADDRESS.ADDRESS_LINE1,0,4) LIKE '4389';
no rows selected
編輯補充:
SQL> desc mortal
Name
--------------------------
MORTAL_ID
SEX_TYPE_CODE
FIRST_NAME
LAST_NAME
DOB
MARITAL_STATUS_CODE
SSN
MIDDLE_NAME
WORK_PHONE
SQL> desc Mortal_address
Name
--------------------------
ADDRESS_ID
MORTAL_ID
SQL> desc address
Name
--------------------------
ADDRESS_ID
ADDRESS_TYPE_CODE
ZIP_CODE
STATE_CODE
ADDRESS_LINE1
CITY
ADDRESS_LINE2
ADDRESS_LINE3
COUNTRY
如果沒有where子句,你會得到什麼嗎?您的連接是否正確/ – smk
您能向我們展示MORTAL和MORTAL_ADDRESS的DDL以及應該返回的那些表中的數據嗎?這將有助於確定問題。 – MichaelMilom
好吧,堅持,我編輯我的帖子 –