I tried to figure out the questions answer but after thinking differently I able to find the right answer. Here I try to explain a little bit with the one which I felt hard to finding the answer or hard to understand.
Answer the questions below:
QA-1: Using the tools_db database, what is the tool with the longest name based on character length?
Answer: Here I struggled and try to get help of the hints section but still couldn't understand.
The hints says "Use the LENGTH() function and sort the tool name in descending order".
So the SQL Command looks like as per hints and with the learnings:
mysql> SELECT LENGTH(name) AS name FROM hacking_tools ORDER BY name DESC;
But this won't show you the actual results, see the screenshot:
The results showing only the number of characters, but we need the name also. For this we need to change a bit on the command only then we will get answer.
For that use:
mysql> SELECT name, LENGTH(name) AS name FROM hacking_tools ORDER BY name DESC;
What I did I just add another query as name to show the name.
Answer Is: USB Rubber Ducky
I hope this is the right way, if you have different approach please share your thoughts.
Comments
Post a Comment