How to order by name asc but have 2 sticky rows??

Discussion in 'MySQL' started by 123GoToAndPlay, Jan 29, 2010.

  1. #1
    Hi,

    What's the simplest/fastest way to select by name but exclude 2 or more rows for sticky, on top of the list placement??
    
    SELECT * FROM artworks ORDER BY name WHERE id != (4,14) ASC ;
    
    Code (markup):
     
    123GoToAndPlay, Jan 29, 2010 IP
  2. 2and1

    2and1 Active Member

    Messages:
    140
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #2
    I'm no expert, pro or even janitor with mysql but I remember 'IN' and '<>' being somewhat good for this.

    Ah here's a link I can't link you to, copy & paste it is then: http://www.webdevelopersnotes.com/tutorials/sql/tutorial_mysql_in_and_between.php3

    Also it's not a good idea to select '*' as you will select every single row/field before it's sorted, though I guess this is mainly discouraged for large tables.
     
    2and1, Jan 29, 2010 IP
  3. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #3
    SELECT * FROM artworks WHERE id NOT IN (4,14) ORDER BY name ASC ;
     
    jestep, Jan 29, 2010 IP