If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Combining 2 queries

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-04-07, 14:17
anjanesh anjanesh is offline
Registered User
 
Join Date: Feb 2005
Location: Mumbai, India
Posts: 161
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
Reply With Quote
  #2 (permalink)  
Old 01-04-07, 17:14
Yveau01 Yveau01 is offline
Registered User
 
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)

Reply With Quote
  #3 (permalink)  
Old 01-04-07, 21:04
anjanesh anjanesh is offline
Registered User
 
Join Date: Feb 2005
Location: Mumbai, India
Posts: 161
Thanks a lot !
__________________
MySQL 5.1
Reply With Quote
  #4 (permalink)  
Old 01-05-07, 06:42
Yveau01 Yveau01 is offline
Registered User
 
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)

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On