0

This is php/mysql code

$view->pch = $db->Query("SELECT from_unixtime(`pauc_date`), `pauc_ad_id`, `pauc_domain`, `pauc_word`, `pauc_referer`, `pauc_ip`, `pauc_country` FROM publisher_ad_units_clicks WHERE pauc_user_id=?", "i", $USER_ID); 

I need to change this query to get only last 100 rows. because table has thousands of rows and slow down the page loading.

2 Answers 2

1

You can use MySQL ORDER BY..LIMIT:

SELECT from_unixtime(pauc_date), pauc_ad_id, pauc_domain, pauc_word, pauc_referer, pauc_ip, pauc_country FROM publisher_ad_units_clicks where pauc_user_id=? ORDER BY pauc_date DESC LIMIT 100 
Sign up to request clarification or add additional context in comments.

4 Comments

What do you mean by 'not working' , is it throwing an error? not the correct results?
i think problem with, where pauc_user_id=? page not loading HTTP ERROR 500
problem with using ORDER BY pauc_date DESC LIMIT 100 after pauc_user_id=?","i",$USER_ID
thisis my full code with your answer $view->pch = $db->Query("SELECT from_unixtime(pauc_date), pauc_ad_id, pauc_domain, pauc_word, pauc_referer, pauc_ip, pauc_country FROM publisher_ad_units_clicks where pauc_user_id=?","i",$USER_ID ORDER BY pauc_date DESC LIMIT 100 );
0

You need to use limit in your mysql query. Reference

$view->pch = $db->Query("SELECT from_unixtime(`pauc_date`), `pauc_ad_id`, `pauc_domain`, `pauc_word`, `pauc_referer`, `pauc_ip`, `pauc_country` FROM publisher_ad_units_clicks WHERE pauc_user_id=? LIMIT 0, 100", "i", $USER_ID); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.