reubenb
10-18-2005, 02:33 PM
hi there,
what is wrong with the SQL below?
i have 10 tables and i want to get the combined top 5 from all of them ordered by date.
why doesnt it work?
there is no error, it just doesnt display any data
thanks
<p class="maintext">Recently Added<br>
<%
CreateConn()
SQL = "SELECT TOP 5 articles_title, type, articles_id, articles_level, articles_category, articles_subcategory, articles_addedbydate FROM articles WHERE articles_level >= " & author_status & "
UNION ALL SELECT TOP 5 songslyrics_title, type, songslyrics_id, songslyrics_level, songslyrics_category, songslyrics_subcategory, songslyrics_addedbydate FROM songslyrics WHERE songslyrics_level >= " & author_status & "
UNION ALL SELECT TOP 5 images_title, type, images_id, images_level, images_category, images_subcategory, images_addedbydate FROM images WHERE images_level >= " & author_status & "
UNION ALL SELECT TOP 5 videos_title, type, videos_id, videos_level, videos_category, videos_subcategory, videos_addedbydate FROM videos WHERE videos_level >= " & author_status & "
UNION ALL SELECT TOP 5 websites_title, type, websites_id, websites_level, websites_category, websites_subcategory, websites_addedbydate FROM websites WHERE websites_level >= " & author_status & "
UNION ALL SELECT TOP 5 peulot_title, type, peulot_id, peulot_level, peulot_category, peulot_subcategory, peulot_addedbydate FROM peulot WHERE peulot_level >= " & author_status & "
UNION ALL SELECT TOP 5 quotations_title, type, quotations_id, quotations_level, quotations_category, quotations_subcategory, quotations_addedbydate FROM quotations WHERE quotations_level >= " & author_status & "
UNION ALL SELECT TOP 5 generalchinuch_title, type, generalchinuch_id, generalchinuch_level, generalchinuch_category, generalchinuch_subcategory, generalchinuch_addedbydate FROM generalchinuch WHERE generalchinuch_level >= " & author_status & "
UNION ALL SELECT TOP 5 keythemesquestions_title, type, keythemesquestions_id, keythemesquestions_level, keythemesquestions_category, keythemesquestions_subcategory, keythemesquestions_addedbydate FROM keythemesquestions WHERE keythemesquestions_level >= " & author_status & "
UNION ALL SELECT TOP 5 programideas_title, type, programideas_id, programideas_level, programideas_category, programideas_subcategory, programideas_addedbydate FROM programideas WHERE programideas_level >= "& author_status & " ORDER BY articles_addedbydate ASC"
CreateRS()
Do While Not ObjRS.EOF
%>
egweg
<a href="view.asp?id=<%=objRS("articles_id")%>&type=<%=objRS("type")%>">
<%=objRS("articles_title")%></a><br>
<%
ObjRS.MoveNext
Loop
%>
</p>
what is wrong with the SQL below?
i have 10 tables and i want to get the combined top 5 from all of them ordered by date.
why doesnt it work?
there is no error, it just doesnt display any data
thanks
<p class="maintext">Recently Added<br>
<%
CreateConn()
SQL = "SELECT TOP 5 articles_title, type, articles_id, articles_level, articles_category, articles_subcategory, articles_addedbydate FROM articles WHERE articles_level >= " & author_status & "
UNION ALL SELECT TOP 5 songslyrics_title, type, songslyrics_id, songslyrics_level, songslyrics_category, songslyrics_subcategory, songslyrics_addedbydate FROM songslyrics WHERE songslyrics_level >= " & author_status & "
UNION ALL SELECT TOP 5 images_title, type, images_id, images_level, images_category, images_subcategory, images_addedbydate FROM images WHERE images_level >= " & author_status & "
UNION ALL SELECT TOP 5 videos_title, type, videos_id, videos_level, videos_category, videos_subcategory, videos_addedbydate FROM videos WHERE videos_level >= " & author_status & "
UNION ALL SELECT TOP 5 websites_title, type, websites_id, websites_level, websites_category, websites_subcategory, websites_addedbydate FROM websites WHERE websites_level >= " & author_status & "
UNION ALL SELECT TOP 5 peulot_title, type, peulot_id, peulot_level, peulot_category, peulot_subcategory, peulot_addedbydate FROM peulot WHERE peulot_level >= " & author_status & "
UNION ALL SELECT TOP 5 quotations_title, type, quotations_id, quotations_level, quotations_category, quotations_subcategory, quotations_addedbydate FROM quotations WHERE quotations_level >= " & author_status & "
UNION ALL SELECT TOP 5 generalchinuch_title, type, generalchinuch_id, generalchinuch_level, generalchinuch_category, generalchinuch_subcategory, generalchinuch_addedbydate FROM generalchinuch WHERE generalchinuch_level >= " & author_status & "
UNION ALL SELECT TOP 5 keythemesquestions_title, type, keythemesquestions_id, keythemesquestions_level, keythemesquestions_category, keythemesquestions_subcategory, keythemesquestions_addedbydate FROM keythemesquestions WHERE keythemesquestions_level >= " & author_status & "
UNION ALL SELECT TOP 5 programideas_title, type, programideas_id, programideas_level, programideas_category, programideas_subcategory, programideas_addedbydate FROM programideas WHERE programideas_level >= "& author_status & " ORDER BY articles_addedbydate ASC"
CreateRS()
Do While Not ObjRS.EOF
%>
egweg
<a href="view.asp?id=<%=objRS("articles_id")%>&type=<%=objRS("type")%>">
<%=objRS("articles_title")%></a><br>
<%
ObjRS.MoveNext
Loop
%>
</p>