Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL statement with PHP - Select the latest added row from each vendor
    primarykey
    data
    text
    <p>This question is probably easy to solve, but here it comes.</p> <p>I would like to get the latest data from each vendor (the latest row inserted into the database for each vendor).</p> <p>This is some sample data from MySQL:</p> <pre> id vendorId vendor url delay price0 price1 price2 price3 price4 price5 price6 date 1 1 vendor1 vendor1.com 0 12 15 18 14 25 28 25 2012-01-18 09:43:40 2 2 vendor2 vendor2.com 0 12 15 18 14 25 28 25 2012-01-18 09:43:40 3 1 vendor1 vendor1.com 0 15 17 122 12 30 52 53 2012-01-18 10:02:40 4 2 vendor2 vendor2.com 0 13 12 123 16 54 61 91 2012-01-18 10:02:40</pre> <p>I would like the output to be:</p> <pre> id vendorId vendor url delay price0 price1 price2 price3 price4 price5 price6 date 3 1 vendor1 vendor1.com 0 15 17 122 12 30 52 53 2012-01-18 10:02:40 4 2 vendor2 vendor2.com 0 13 12 123 16 54 61 91 2012-01-18 10:02:40</pre> <p>What would the SQL be and how would I put the values into this array?</p> <pre> $vendor = array( array('vendorId' => '1', 'vendor' => 'vendor1', 'url' => 'vendor1', 'delay' => 0, 'price0' => 12, 'price1' => 15, 'price2' => 26, 'price3' => 14, 'price4' => 25, 'price5' => 64, 'price6' => 512), array('vendorId' => '2', 'vendor' => 'vendor2', 'url' => 'vendor2', 'delay' => 0, 'price0' => 12, 'price1' => 15, 'price2' => 26, 'price3' => 14, 'price4' => 25, 'price5' => 64, 'price6' => 512) );</pre> <p>Thanks in advance</p> <p>Also, I forgot to mention: There will be more than just 2 vendors in the database, so I'd prefer that they'd be picked up per auto.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload