Ok, so i have taken a look at many threads on here and MSDN about paging in SQL 2005.
All seem to be working on fairly simple queries getting one or two columns.
I have a query that is very large, it gets at least 15 columns from 3 tables and then adds search related items to the where clause and finally orders by a user selected field.
My question is how to know where to start with the paging hacks....
I am from a mysql, postgres, oracle background and finding this to be a bit of an oversight in SQL 2005... my recordset total is inxs of 20k records, so clientside paging is simply not an option.
Here is the query;-
Suggestions greatly appreciated.
Jez
All seem to be working on fairly simple queries getting one or two columns.
I have a query that is very large, it gets at least 15 columns from 3 tables and then adds search related items to the where clause and finally orders by a user selected field.
My question is how to know where to start with the paging hacks....
I am from a mysql, postgres, oracle background and finding this to be a bit of an oversight in SQL 2005... my recordset total is inxs of 20k records, so clientside paging is simply not an option.
Here is the query;-
Code:
$resultArr = array();
$limit = "TOP (100)";
$seriesSql = " SELECT $limit
st.Series_Id,
st.Title_Id,
st.Series_Name,
st.Programme_Name,
st.Synopsis,
st.Language_Code,
st.Demographic_Id,
st.Channel_Code,
st.PDS_Common_Property_Id,
M.Material_Id,
M.Title_Id,
M.Series_Id,
MT.Marketing_Title,
CONVERT(VARCHAR(10), MT.Start_Date, 111) AS Start_Date,
CONVERT(VARCHAR(10), MT.Start_Date, 108) AS Start_Time,
CONVERT(VARCHAR(10), MT.End_Date, 111) as End_Date,
CONVERT(VARCHAR(10), MT.End_Date, 108) as End_Time
FROM Series_Titles st
LEFT JOIN Material M ON
st.Series_Id = M.Series_Id AND
st.Title_Id = M.Title_Id AND
st.Language_Code = M.Language_Code AND
st.Channel_Code = M.Channel_Code
LEFT JOIN Marketing_Titles MT ON
MT.Series_Id = st.Series_Id AND
MT.Title_Id = st.Title_Id
";
if($filter_text){
$extraSql[] = " M.Material_Id LIKE '%".$filter_text."%'";
}
if($this->langCodeSearchTerm){
$extraSql[] = "st.Language_Code = '".$this->langCodeSearchTerm . "'";
}
if($this->channelCodeSearchTerm){
$extraSql[] = "st.Channel_Code = '".$this->channelCodeSearchTerm . "'";
}
if($this->titleStringSearchTerm){
$extraSql[] = "st.Programme_Name LIKE '%".$this->titleStringSearchTerm . "%'";
}
if($this->seriesStringSearchTerm){
$extraSql[] = "st.Programme_Name LIKE '%".$this->seriesStringSearchTerm . "%'";
}
if(count($extraSql) > 0 ){
$seriesSql .= " WHERE " . implode(" AND ", $extraSql);
}
print_r($seriesSql);
Suggestions greatly appreciated.
Jez