简体   繁体   中英

Oracle Express 11g command

I'm trying to run a SQL command with Oracle Express 11g, and it's giving me an error message:

no rows selected

SELECT EMPLOYEE_ID, EMPLOYEE_NAME, DEPARTMENT_NAME
FROM EMPLOYEES JOIN DEPARTMENTS USING (DEPARTMENT_ID)
WHERE EMPLOYEE_ID < 103
AND EMPLOYEE_ID > 203;

The question asks: The employee identification number, employee name, and department name for all employees whose identification number is less than 103 OR greater than 203.

Your code uses the and logical operator instead of the or operation. Since a number (the ID, in this case) cannot be both less than 103 and greater than 203, you will get no rows.

Just replace the and with an or and you should be fine:

SELECT EMPLOYEE_ID, EMPLOYEE_NAME, DEPARTMENT_NAME
FROM   EMPLOYEES 
JOIN   DEPARTMENTS USING (DEPARTMENT_ID)
WHERE  EMPLOYEE_ID < 103 OR  EMPLOYEE_ID > 203;
-- Here -----------------^

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM