Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written stored procedure to fetch queries from data, Here is the code :

SQL
BEGIN
SELECT `posts`.`id`, `title`, `slug`, `image`,`labelid` FROM posts JOIN postlabels ON (posts.id=postlabels.postid and unpublish='0') WHERE labelid='13' ORDER BY `posts`.`id` DESC LIMIT 5;
SELECT `posts`.`id`, `title`, `slug`, `image`,`labelid` FROM posts JOIN postlabels ON (posts.id=postlabels.postid and unpublish='0') WHERE labelid='14' ORDER BY `posts`.`id` DESC LIMIT 5;
END


But after execution , i am getting only the first query from database , How to fetch remaining 'n' queries !
Posted

1 solution

You haven't given any real information as to how you want the data to later be used.

If I presume you're looking for a single record set:

If you place keyword UNION between each select statement you'll get back a single record set containing all of your requested records. They will be unique throughout all of the UNION. If you wish to allow non-unique entries, use UNION ALL.

If not looking for a single recordset:

If you're returning multiple record-sets for output in different sections, you would probably be best off running each query separately and then updating the appropriate area - rather than a single query returning multiple record sets. This allows you to take into account empty record sets if locations are very specific.

 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900