I have 2 tables as follows:
Table1: Studen(Studen_ID, Name, Class_ID)
Table2: Class(Class_ID,ClassName)
- When I INNER JOIN these 2 tables together, it works fine:
Quote:
$stmt = "SELECT Studen_ID,Name,ClassName FROM Studen
INNER JOIN Class
ON Studen.Class_ID=Class.Class_ID
WHERE TenNhanVien LIKE '%".$strKeyword."%' ";
- But when I perform paging, report an error:
Quote:
$stmt = " SELECT Name,Studen_ID FROM
(SELECT ROW_NUMBER() OVER(ORDER BY Name) AS RowID,Name,Studen_ID FROM Studen WHERE Name LIKE '%".$strKeyword."%'
) AS Studen_ID
WHERE Studen_ID.RowID > $row_start AND Studen_ID.RowID <= $row_end
";
-Class name does not display data.
Hope the helping.
Thank you very much!
$stmt = " SELECT Name,Studen_ID FROM
(SELECT ROW_NUMBER() OVER(ORDER BY Name) AS RowID,Name,Studen_ID FROM Studen WHERE Name LIKE '%".$strKeyword."%'
) AS Studen_ID
WHERE Studen_ID.RowID > $row_start AND Studen_ID.RowID <= $row_end
It is conflict blue and red
Code (PHP)
$stmt = " SELECT Name,Studen_ID
FROM(
SELECT ROW_NUMBER() OVER(ORDER BY Name) AS RowID,Name,Studen_ID
FROM Studen WHERE Name LIKE '%".$strKeyword."%'
) AS tmp
WHERE tmp.RowID > $row_start AND tmp.RowID <= $row_end
";
Please try
$result = sqlsrv_query(........) or die( print_r( sqlsrv_errors(), true));
You can see error and Notice for resolve it by yourself.
$stmt = " SELECT Name,Studen_ID
FROM(
SELECT ROW_NUMBER() OVER(ORDER BY Name) AS RowID,Name,Studen_ID
FROM Studen WHERE Name LIKE '%".$strKeyword."%'
) AS tmp
WHERE tmp.RowID > $row_start AND tmp.RowID <= $row_end
";
$stmt = " SELECT tmp.Name, tmp.Studen_ID, c.ClassName
FROM(
SELECT ROW_NUMBER() OVER(ORDER BY Name) AS RowID,Name,Studen_ID, Class_ID
FROM Studen WHERE Name LIKE '%".$strKeyword."%'
) AS tmp
left join Class c on tmp.Class_ID = c.Class_ID
WHERE tmp.RowID > $row_start AND tmp.RowID <= $row_end
";
Thank you Thaicreate and Mr Chaidhanan community very much. I just learned about php so I don't have much experience. Looking forward to learning and sharing from the Thaicreate community and Mr Chaidhanan help.
Thank you!