Wordpress; updated SQL query code for a very small function

I need a custom Wordpress function that will return an array of oldest values from the database.

For this example; I have created a bunch of custom posts ('machine') in Wordpress. Each custom post has been assigned two custom metadata keys; 'last_updated_timestamp' and 'serial_number'. Timestamps are in epoch format (i.e. '1557240847').

This is the code that I have so far, and it returns an array of serial numbers as expected. Although, I need the SQL query updated, as to instead return the OLDEST serial numbers found in the database, based on their metadata keys 'last_updated_timestamp'.

function get_oldest_serial_numbers($limit = 10) {

global $wpdb;

$result = $wpdb->get_col( $wpdb->prepare("

SELECT pm.meta_value FROM {$wpdb->postmeta} pm

LEFT JOIN {$wpdb->posts} p ON [login to view URL] = pm.post_id

WHERE pm.meta_key = 'serial_number'

AND p.post_status = 'publish'

AND p.post_type = 'machine'



return $result;


Compétences : MySQL, PHP, SQL, WordPress

en voir plus : wordpress functions cheat sheet, wordpress functions.php example, wordpress custom sql query, wordpress functions tutorial, wordpress functions pdf, wordpress sanitize html, wordpress custom functions, how to fetch data from database in wordpress page, sql query tree structure records, asterisk call forward database sql query, wordpress code sort function, wordpress sql query posts category, wordpress custom sql query terms, sql query wordpress custom fields, wordpress custom sql query posts, writing sql query wordpress, wordpress code search function, small sql query, wordpress custom sql query categories, wordpress code call function

Concernant l'employeur :
( 6 commentaires ) Helsingborg, Sweden

Nº du projet : #19468540

Décerné à:


Hello, My name is Sergey. I am Freelancer from Saint Petersburg, Russia. I can help you as an experienced WordPress programmer to update your code/SQL to return the OLDEST serial numbers found in the database, based o Plus

%selectedBids___i_sum_sub_4% %project_currencyDetails_sign_sub_5% USD en 1 jour
(1829 Commentaires)

21 freelance font une offre moyenne de $27 pour ce travail


Hello there Myself having has 10 + years experience of web site development. Expert in Custom programming in php / Mysql / Jquery /Laravel/ Code Igniter/ Prestashop/ Drupal/ Wordpress/ Joomla / OSC / Magento /OpenCart Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(253 Commentaires)

Hello. I 'm expert in "PHP, SQL, WordPress, MySQL" and I have working for 7+ years in this field. I 'm very interest to your project. I have checked your project description carefully and i can do it. I 'll do my best Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(102 Commentaires)

Hello there! how are you doing? if the project is fairly paid I can build you a small part of it as form of a demo, afterwards you'll decide if you should hire me or not so don't hesitate to contact me even though you Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(55 Commentaires)

Hello sir, I am good at : 1. WordPress, Shopify, Magento, Opencart, Joomla web development 2. PSD to HTML 3. Responsive web development 4. Graphics Designing 5. Photoshop 6. PHP 7. html + CSS Styling 8. js & jQuery. Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(100 Commentaires)

Hi sir, i understand you need to update SQL query code for your project. i am sharing my few projects with you, please go through... 1. [login to view URL] 2. [login to view URL] 3. [login to view URL] 4. htt Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(56 Commentaires)

Hi! I am an expert of PHP programming can work to update your SQL query in your wordpress. please kindly contact me for more further discussion, thank you.

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(35 Commentaires)

Hello I can update the query that you have to return the oldest serial numbers first based on their metadata keys 'last_updated_timestamp'. You can always contact me if you have any questions. Thanks.

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(33 Commentaires)

Hello, Thanks for job posting. I have read the description carefully and give you 100% assistance as Wordpress Developer updated SQL query code for a very small function Skills- PHP, WordPress, Woocommerce, genesis, Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 2 jours
(16 Commentaires)

As I understood, you need the records in descending order of the last_updated_timestamp I think it may be a quick tweak on that query by adding order by in it. Let's discuss more if both of us are in same track

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(22 Commentaires)

Good understanding in languages including PHP, MySql, SQL SERVER 2012 , Sql WorkBench, Laravel, CodeIgniter, WordPress, WordPress Themes, WordPress Plugins, HTML5, CSS3, Javascript, Jquery, Json, E-Commerce, Woo- Com Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(8 Commentaires)

Dear Client, Hope You are fine, As a professional web developer I have build so many website and i have read your requirement and I can do this task We will discuss task in detail in Chat Skills: PHP, MVC (Codeigni Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(4 Commentaires)

Hi there, Hope you are doing great!. I am expert and can surely assist you with my service in updating the query right now via ANY DESK. Looking forward for your positive response. Best Regards, Ijaz Hussa Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(4 Commentaires)

Hello It's a piece of cake. i have experienced to work with client from [login to view URL] can find it in my portfolio I can help you to do it perfectly If you hire me, i can start right now and i will do my best for us th Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(3 Commentaires)

Hi, very interesting and not hard job for me. I have fully understood your requirement. This is an agile programmer with more than 7 years experience. I graduated of BScH Computer Science who possesses an interesting a Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(6 Commentaires)

I understand your requirement and I assure that I'm the perfect choice for this task. I can complete this project in 1 hour and I am looking forward to discussing it. Please send me a message for discussion. I am 8+ Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(2 Commentaires)

Hello, sir. Much interested in your project, and I'd read all of your requirements carefully. I'm thinking this is the suitable one you're looking for. I'd like to talk with you over chat, share more details of your re Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(1 Évaluation)

Hudson Agile Technologies LLC – A New Jersey Firm. Entity ID – 0450219485 We are head quartered in 30 Knightsbridge Rd Suite 525, Piscataway Township, NJ 0885 We are a Software Technology Outsourcing consulting Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(0 Commentaires)

Dear Client, I have around 4+ years of experience in web development & designing field. I have experienced to solve various tasks/issues. My main concern is provide better solution to you so that I will nice feedba Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(0 Commentaires)

Hello. I can help you. I have enough experience and high skill in Wordpress, PHP , SQL. You will be satisfied with my work. Thank you.

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 7 jours
(0 Commentaires)

Hello there, I'm a fullstack developer with over 8 years experience of web development. Could we discuss more details? Sincerely. Jin.

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 7 jours
(0 Commentaires)