minni — 2014-01-03T03:39:27-05:00 — #1
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 !!!!
swampboogie — 2014-01-03T04:04:09-05:00 — #2
where mod(priestid,4) = 1
felgall — 2014-01-03T04:06:03-05:00 — #3
Of course with mysql_query now long dead and about to be removed from PHP you really ought to be using mysqli_query instead.
minni — 2014-01-03T04:25:40-05:00 — #4
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...
r937 — 2014-01-03T06:43:27-05:00 — #5
FROM priest AS t
WHERE MOD( ( SELECT COUNT(*)
WHERE priestid < t.priestid ),4) = 0