Ask AI on The Internet
Question: CREATE TABLE STAFF ( STAFF_ID CHAR(3),STAFF_NAME CHAR(20),PRIMARY KEY (STAFF_ID), FOREIGN KEY (BOSS_ID) REFERENCES STAFF (STAFF_ID));CREATE TABLE COURSE ( COURSE_ID CHAR(6),COURSE_TITLE CHAR(20),STAFF_ID CHAR(3), PRIMARY KEY (COURSE_ID), FOREIGN KEY (STAFF_ID) REFERENCES STAFF(STAFF_ID)); List the names of all courses that are taught by the staff members BEAN or SAM
To retrieve the names of all courses that are taught by the staff members BEAN or SAM, you can use the following SQL query: ``` SELECT COURSE_TITLE FROM COURSE WHERE STAFF_ID IN ( SELECT STAFF_ID FROM STAFF WHERE STAFF_NAME LIKE 'BEAN%' OR STAFF_NAME LIKE 'SAM%' ); ``` This query uses a subquery to find the `STAFF_ID` values of the staff members with names that start with "BEAN" or "SAM". The outer query then retrieves the `COURSE_TITLE` values for all courses whose `STAFF_ID` is in that list of IDs. Note that the `%` character is a wildcard that matches any string, so `LIKE 'BEAN%'` matches any string that starts with "BEAN".
March 21, 2023, 8:09 a.m.
A new large language model has been made available since this question was asked.
To generate an updated answer from the new model, click the button below.
Think your answer is better than the AI's? Post it below.
Other Most Relevant Posts:
Question Tags
If you want your question answered by an AI, click here.
Post your own comment: