Reputation:
How can i select all the id's from a table, and let select all the songs with the id;s from the other table?
$query = "SELECT * FROM songs WHERE id = (SELECT songid FROM top10 order by id)'";
Upvotes: 0
Views: 93
Reputation: 62851
You can use IN
for that (or EXISTS
):
select *
from songs
where id in (
select songid
from top10 )
Based on your comments, you might actually be looking to use JOIN
(just realize if there are duplicate records in the top10 table, this could return duplicate results):
select s.*
from songs s
join top10 t on s.id = t.songid
order by t.id
Upvotes: 6