Hello, I need help with MYSQL. I already started working on it. And this is what
ID: 3807851 • Letter: H
Question
Hello, I need help with MYSQL.
I already started working on it. And this is what I have so far:
DELIMITER //
CREATE FUNCTION fHW2_4_argonzal(INp varchar(35))
RETURNS varchar(35)
BEGIN
DECLARE output varchar(255);
SET output = '';
IF(INp = '' OR INp is NULL) THEN
SET output = 'Please input a valid city.';
Select output;
ELSE
SET output = 'Select guestname from dreamhome.Guest where guestaddress like CONCAT('%',INp,'%') order by guestname;’;
END IF;
RETURN output;
END //
DELIMITER ;
The Bold part is what I am a little confused about. The query works perfectly the output is the correct. However, I am not too sure of how to make it look like the assignment sample output in 4A. I am also not sure of how to output no results found where there is an empty set for part 4c.
+--------------+
| guestname |
+--------------+
| John Kay |
| Mike Ritchie |
+--------------+
4. (30 points Please write a stored function named fHW2 4 XXXX based on the Guest table. Your program should take one argument city and it should meet the following 3 test cases. 10 points) If the given city is in the 4B. (10 points) If the given city is empty 4A. Guest table, please return text with names for all or NULL, please display "Please input a valid city guests whose address includes the given city mysqP select fHW2 4 xxxx(') as output; mysqP select ffw2 4 xxxx( London) as output mysql select fHW2 4 xxxx(NULL) as output; output output l Please input a valid city I I John Kay Mike Ritchie l AC. 10 points) If the given city is not in the Guest table, please display "No result found mysqP select fHW2 4 xxxx( Union') as output l output I No result foundExplanation / Answer
Select GuestName From fHW2_4_argonzal where (guestadress=INp);
if you want all the data regarding the city name then you can use orderby here it is not needed
now for part 4c you need to use ifelse statement here so for your first if statement if you entered a empty city or if you do enter a null value then you get your second output now in if else if a city is matched with the address name then the guestname is displayed so now if you enter a value and if it is not there you get a output if
Else
SET Output ="not found";
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.