FooBar
FooBar

Reputation: 6138

Order by a VIEW list of user_ids

I have a VIEW that keeps track of how a specific user (author) interacts with other users (receiever). See VIEW:

the table

Here you can see how AUTHOR (the user_id) interacts with the other users by posting on his wall (post), liking their stuff (like) and also follows. Is there a way I can order the table POSTS with this VIEW? What I'd like to achieve is to show the wall posts (table: posts) and move the most relevant posts (the posts where the reciever ID appear most).

The posts table looks like this:

posts table

I'd like to order the post_author (from above table) against receiver (in the view).

Any ideas?

Upvotes: 0

Views: 30

Answers (1)

jaczes
jaczes

Reputation: 1404

Yes, You have to bulid a variable wich contains all ID's in correct order nad put them into field() function

ORDER BY FIELD(ID, (id's to order by))

EDIT: Here is tutorial: http://www.imthi.com/blog/programming/mysql-order-by-field-custom-field-sorting.php

Upvotes: 1

Related Questions