This community-built FAQ covers the “Code Challenge 9” exercise from the lesson “Code Challenge: Queries”.
Paths and Courses
This exercise can be found in the following Codecademy content:
Web Development
Data Science
FAQs on the exercise Code Challenge 9
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply (
) below!
Agree with a comment or answer? Like (
) to up-vote the contribution!
Need broader help or resources? Head here.
Looking for motivation to keep learning? Join our wider discussions.
Learn more about how to use this guide.
Found a bug? Report it!
Have a question about your account or billing? Reach out to our customer support team!
None of the above? Find out where to ask other questions here!
I have a kind of general question. The timestamp values make no sense to me, so I didn’t understand why we need to put them in DESC order. Can someone explain what this number means so that I can understand why we ordered it this way?
2 Likes
In this exercise we are asked to find 20 recent articles from Business category.
I want to go further and find 20 recent articles in both Business and Technology categories . Unfortunately, my query didn’t work:
select * from news
where category = ‘t’ or category = ‘b’
group by category
limit 20;
I also tried another variation of where like category = ‘t’ or ‘b’ - also didn’t work.
Also tried this
select * from news
group by category
having category = ‘b’ or category = ‘t’
limit 20;
How can I combine search for two categories and why my queries didn’t work?
If you want the 20 most recent articles, shouldn’t use order by?
where category = ‘t’ or category = ‘b’
should work, or you could use: WHERE category IN ('b', 't')
.
Anyway, if we do:
select * from news
where category = ‘t’ or category = ‘b’
order by timestamp des;
(which codecademy doesn’t like), we can see of all the most recent articles, they are all in tech, not Business.
1 Like
Is the IS operator the same as “=”? I thought = was only used from numbers, but then I saw it used instead of IS in the exercise. My query with IS worked, but I wasn’t sure what the rule/best practice is.
have you tried to google if is
and =
are the same thing? Understanding the difference is highly recommended.
Yes, I did Google it, but all of the answers I found are in relation to the NULL value. I thought that this forum was for questions on the exercises in Codecademy. Would appreciate some help on the concept.
So that answers the question? =
checks for equality, is
checks if value is a null value
we can’t use =
for checking if value equals NULL, because null means no value.
1 Like
OK, now I get it. IS only applies to NULL. Otherwise, = is the correct operator. Thank you.
2 Likes
Why does swapping ORDER and LIMIT yield no results?
SELECT * FROM news
WHERE category = ‘b’
LIMIT 20
ORDER by timestamp DESC;
(I understand that this could change the list you obtain; I am just curious why this finds nothing)
SELECT * FROM news
WHERE category = ‘b’ AND title LIKE’SEC%’
ORDER BY timestamp DESC
LIMIT 20;Practicing with other CLAUSES you have learned is important and interesting
i dont want to soud bad, but it would be kind if students would ofter get a reply from moderators on interesting questions, as this is a paid course. could anyone help?