Home Select Top 1 from one table and all linked values from another in SQL
Reply: 1

Select Top 1 from one table and all linked values from another in SQL

andyc209
1#
andyc209 Published in 2017-12-05 16:51:06Z

I have two tables

Table Tbl_Headline

ID_key
News_Type

Table Tbl_Item

Item_ID
ID_key

I need to get the top 1 from Tbl_Headline but all the Item_ID's from the second table that match on that ID_key in one query

Probably code 101 but I'm having a mental block

Thanks for any help

spacejester
2#
spacejester Reply to 2017-12-05 17:06:30Z

I think I've understood the question correctly... Does this help?

SELECT
   a.*, b.*

FROM
   Tbl_Headline a
   JOIN Tbl_Item b ON a.ID_key = b.ID_key

WHERE
   a.ID_key = (SELECT TOP 1 ID_key FROM Tbl_Headline)
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.309136 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO