I have a table that contains posts and another table that contains meta options for each post in first table. The meta options table is a key value pare table.
Lets say I have the posts tables that look like that
Posts
---------------------------------------------
id | Other columns ....
---------------------------------------------
1 | data ...
2 | data ...
3 | data ...
4 | data ...
5 | data ...
and the meta options table that look like that
Meta
---------------------------------------------
id | post_id | meta_key | meta_value
---------------------------------------------
1 | 1 | views | 5
2 | 1 | maxViews | 100
3 | 2 | views | 0
4 | 2 | maxViews | 1000
5 | 1 | publisOn | 2013-05-14 10:41
6 | 1 | auhor | MyUser
7 | 2 | auhor | Another author
The question is, how can I get the post with id equals to 1 by making a comparison of the meta_key values views and maxViews.
For example, I like to retrive the post id with ID 1 only if the views is lower than the masViews in the Meta table.
Any help please ?