Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/30/2021 in all areas

  1. I am not psychic. Only you currently know what sequence you want. Only you know which column you would need to sort on to get that desired sequence (and if such a column even exists). Here's a start... SELECT * -- DON'T use *, specify the columns you want. , news.id as nid FROM news LEFT JOIN category ON category.id=news.catid ORDER BY ??????????????????? LIMIT $lim OFFSET $offset;
    1 point
  2. If I just get the records from my user table they appear in the order they are stored SELECT user_id , firstname , lastname , username , dob FROM user; +---------+-----------+----------+----------+------------+ | user_id | firstname | lastname | username | dob | +---------+-----------+----------+----------+------------+ | 1 | Peter | Dowt | peterd | 2009-12-21 | | 2 | Laura | Norder | lauran | 2010-10-22 | | 3 | Tom | DiCanari | tomd | 2007-10-24 | | 4 | Scott | Chegg | cheggs | 2008-03-08 | | 5 | Polly | Vinyl | pollyv | 2010-12-15 | | 6 | Polly | Styrene | pollys | 2005-08-20 | | 7 | Tom | Catt | tomc | 2011-02-17 | +---------+-----------+----------+----------+------------+ However, I want to list then in order of their dates of birth (dob column) so add an order by clause to the query SELECT user_id , firstname , lastname , username , dob FROM user ORDER BY dob; +---------+-----------+----------+----------+------------+ | user_id | firstname | lastname | username | dob | +---------+-----------+----------+----------+------------+ | 6 | Polly | Styrene | pollys | 2005-08-20 | | 3 | Tom | DiCanari | tomd | 2007-10-24 | | 4 | Scott | Chegg | cheggs | 2008-03-08 | | 1 | Peter | Dowt | peterd | 2009-12-21 | | 2 | Laura | Norder | lauran | 2010-10-22 | | 5 | Polly | Vinyl | pollyv | 2010-12-15 | | 7 | Tom | Catt | tomc | 2011-02-17 | +---------+-----------+----------+----------+------------+
    1 point
  3. It doesn't matter where in the table the data is stored. When you query your data you want to specify an ORDER BY clause to define what order it will be returned in. If you want the records to display in the order the were added, make sure you have a field that records what date and time the record was added and sort by that field.
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.