i have this table and it can be easily sorted by order by id asc or desc but it will always give same result so there is only possibility of getting two results either by asc or desc here is tablea
id linkid
5454 766
5453 766
5452 766
5451 766
5450 766
5449 766
5448 765
5447 765
5446 765
5445 765
select * from tablea where linkid='766' order by id desc limit 1
or
select * from tablea where linkid='766' order by id asc limit 1
when i use above query i have only two options either to use asc or desc which can sort linkid 766 only in two ways and i will get output of either id 5454 or 5449 but i want to use any one of the id correspnding to linkid .i want output for linkid 766 like this.the query should give any one value not only first or last value which i am getting by using asc or desc but again i dont want to use rand() as it is dead slow
i can try rand() but it will be dead slow
select * from tablea where linkid='766' order by rand() limit 1
any idea how can be achieved.