I have a table called priest and it has only two fields - priestid and priestname.
I want to pick up the rows where priestid=1, 5, 9, 13, 17,..............till the end of the table
That means I want to pick up every 5th row (difference=4).
In know the statement :
select * from priest where priestid in (1,5,9)
But I want mysql to pick up on its own till the end of the table......I am stuck with this.
The following has not worked either:
$result = mysql_query("SELECT * FROM priest where priestid limit $r,1");
Please help !!!!
where mod(priestid,4) = 1
Of course with mysql_query now long dead and about to be removed from PHP you really ought to be using mysqli_query instead.
Thanks a lot... That worked.
One more query.......if I leave the IDs and want to show the priest name of the first row, then priestname form the 5th row, then 9th and so on (irrespective of the IDs), how can it be done??
I have tried this with limit and offset but it did not work...
FROM priest AS t
WHERE MOD( ( SELECT COUNT(*)
WHERE priestid < t.priestid ),4) = 0
This topic is now closed. New replies are no longer allowed.