SQL Server 2008 how to get top record from multiple tables -
i have tables called news
, sports
, technology
, articles
...etc , each table has id, title, content, image, date .. id
primary key in each table, , each table has no relationships, no joins no thing, in same database separated.
what want select last added record each table (just 1 record each table) assuming ordered them id desc
, bind them datalist (latest/shuffle).
so sql query statement should use ?
the records in datalist should this:
news_id news_title news_content news_date technology_id technology_title technology_content technology_date sports_id sports_title sports_content sports_date , on....
any pointers ??
my sql skills not good. appreciated.
regards.
select top 1 news_id, news_title, news_content, news_date news order news_id desc union select top 1 technology_id, technology_title, technology_content, technology_date technology order technology_id desc union select top 1 sports_id, sports_title, sports_content, sports_date sports order sports_id desc
Comments
Post a Comment