|
-
March 15th, 2012, 03:16 PM
#1
Run multiple statements to get result
Hi there
I need to run a query that select some specific results from a table and in addition a number of additional selected results from the same table.
For example, I want to retrieve 20 results from a table of which 5 are already specified and the other 15 can be anything from the table.
I have used the following query but it doesn't work
Code:
Select(
select id,text from table
where id in ('1',
'2',
'3',
'4',
'5')
) as s_id,
(
select id,text
from table limit 15
) as m_tweets
Can someone tell me if there's a way to achive this and how.
Thank you
-
March 15th, 2012, 03:53 PM
#2
Re: Run multiple statements to get result
Ok found the solution
For anyone who wants to run multiple statemtn union all,union will do the job
The syntax is as follow:
Code:
SELECT * FROM table limit 10;
union
SELECT * FROM table limit 20;
Note: If you don't want to get duplicates use union instead of union all.
-
March 19th, 2012, 05:29 PM
#3
Re: Run multiple statements to get result
I think it could be.....
select id,text from table where id in ('1','2','3','4','5')
union
select id,text from table limit 15
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|