Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    161

    Unanswered: Combining 2 queries

    Is there a way to combine this into 1 query ?
    Code:
    SELECT `Word` FROM `List` WHERE `Word` LIKE 'st%' LIMIT 0, 10
    SELECT `Word` FROM `List` WHERE `Word` LIKE '%st%' LIMIT 0, 10
    Problem is, I want the list of results from query1 first and then list from query2
    So if there are 3 from query1 and 2 from query2, I want them in that order.

    SELECT `Word` FROM `List` WHERE `Word` LIKE '%st%' ORDER BY `Word` ASC LIMIT 0, 10 is not the solution since it'll list the words starting from a.

    Thanks
    MySQL 5.1

  2. #2
    Join Date
    Dec 2005
    Location
    Tilburg, Netherlands
    Posts
    73
    Code:
    Select 1
    UNION
    Select 2
    should do the trick ...

    Gr,
    Yveau

    > SELECT * FROM users WHERE clue > 0;
    Empty set (0.00 sec)


  3. #3
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    161
    Thanks a lot !
    MySQL 5.1

  4. #4
    Join Date
    Dec 2005
    Location
    Tilburg, Netherlands
    Posts
    73
    Glad I could help ... that's why we're here for ...

    Gr,
    Yveau

    > SELECT * FROM users WHERE clue > 0;
    Empty set (0.00 sec)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •