Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get one value from an SQL query in php?

Tags:

sql

php

mysql

How do I get the first result of this query using php? I want the first result that is returned when the list is in descending order.

$sql2 = "SELECT orderID FROM orders WHERE 'customerID' = '".$_SESSION['accountID']."' ORDER BY
                    'orderID' DESC";
                $lastorder = mysqli_query($sql2);

Thanks!

like image 261
EGr Avatar asked Jan 28 '26 22:01

EGr


1 Answers

Simply add LIMIT 1 to the end of your SQL

like image 128
Dave Kiss Avatar answered Jan 30 '26 14:01

Dave Kiss



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!