Combining Tables with SQL


#1

i am trying to join the orders and subscriptions tables on subscriptions_ id where description =“fashion magazine”.

select * from orders
join subscriptions
on
orders.subscription_id=subscriptions.subscription_id
where
subscriptions.description=‘Fashion Magazine’
;

but i am getting error of “It looks like you deleted the first query. Be sure to keep both queries for your final submission”.


#2

I’m having an issue with the same exercise

You’ll want to remove the WHERE clause from the bottom of your first query and create another query below it.

My queries are currently coded like this:

SELECT *
FROM orders
JOIN subscriptions
ON subscriptions.subscription_id = orders.subscription_id;

SELECT *
FROM orders
WHERE subscriptions.description = ‘Fashion Magazine’;

But it’s telling me “Did you remember to add the query with the WHERE statement?”

It’s also giving me the error “Error: near line 6: no such column:” if I change the WHERE value.


#3

I figured out the issue.

You want to run the query twice and add the WHERE clause to second like so:

SELECT *
FROM orders
JOIN subscriptions
ON subscriptions.subscription_id = orders.subscription_id;

SELECT *
FROM orders
JOIN subscriptions
ON subscriptions.subscription_id = orders.subscription_id
WHERE description = ‘Fashion Magazine’;


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.