You know what you want to do but you can’t write it in SQL. Welcome to SQL beginner hell!
Tip 1)
English:
I want to show results from one table only if they are present in another table.
SQL:
SELECT raceid FROM races WHERE raceid IN (SELECT raceid FROM raceriders)
This query will only show races that have a row in raceriders. Or in other words, it will only show races which have been assigned riders. Simple huh.
Tip 2)
Avoid using * in simple select statements. Just select the columns you need. It’s more efficient that way. Plus if you make a view sometimes the select * doesn’t update on column alterations. I’m looking at YOU Microsoft SQL Server!
No related posts.