Hello
I have 2 field in my posts table and i want to order the posts with "order_id" first then with "sent_date".
I'm using the following query but it will be order the "order_id" first (for ever)! until with a NULL field or with zero field !!
$sql_query = "
SELECT
posts.post_id,
IF(posts.user_id != -1, users.full_name, posts.poster_name) AS name,
DATE_FORMAT(posts.post_time $get_time_dif_h INTERVAL $get_time_dif HOUR, '$date_format') AS post_time,
posts.title,
cats.title AS cat_title,
posts.head,
IF(posts.img != NULL && posts.img != '', NULL, posts.img ) AS img,
posts.img_width_thumb,
posts.img_height_thumb,
posts.sum_read,
posts.how_see,
users.user_id
FROM
portal_posts AS posts NATURAL LEFT JOIN portal_users AS users
INNER JOIN portal_categories AS cats ON cats.cat_id = posts.cat_id
WHERE
posts.visibility = 1 && posts.is_accept = 1
&& (posts.lang = 'all' || posts.lang = '$default_lang')
ORDER BY posts.order_id, posts.post_time DESC LIMIT $index_total_posts";
Anyone can help me how can i order the posts with order_id first then with sent_date?
NOTE: The type of the order_id field is a small_int.