472,338 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,338 software developers and data experts.

can I write only one select stmt insted of three diff please see the Querys bellow

seshu
156 100+
Hi everybody
Presently Iam write three select statements with diff where and limt conditions but the select stmt in them is same insted of that can i write only one direct stmt and the queries are like this

1)select question,opt1,opt2,opt que_level from questions where que_level=1 limit 4-------here i want only 4 questions whose level is 1 among 100 questions

2)select question,opt1,opt2,opt que_level from questions where que_level=2 limit 5-------here i want only 5 questions whose level is 2 among 100 questions

3)select question,opt1,opt2,opt que_level from questions where que_level=3 limit 7-------here i want only 7 questions whose level is 3 among 100 questions

Please help me out

Regards
Seshu
Jun 20 '07 #1
4 1282
r035198x
13,262 8TB
Hi everybody
Presently Iam write three select statements with diff where and limt conditions but the select stmt in them is same insted of that can i write only one direct stmt and the queries are like this

1)select question,opt1,opt2,opt que_level from questions where que_level=1 limit 4-------here i want only 4 questions whose level is 1 among 100 questions

2)select question,opt1,opt2,opt que_level from questions where que_level=2 limit 5-------here i want only 5 questions whose level is 2 among 100 questions

3)select question,opt1,opt2,opt que_level from questions where que_level=3 limit 7-------here i want only 7 questions whose level is 3 among 100 questions

Please help me out

Regards
Seshu
Perhaps you can use a stored procedure ...
Jun 20 '07 #2
seshu
156 100+
I heard that in mysql 4.1 stored procedures dont work it seems more over i don no how to write a stored procedure so can any one help me with some other way or this is the only way

Regards
Seshu
Jun 20 '07 #3
pbmods
5,821 Expert 4TB
Heya, Seshu.

The only way you could do this effectively would be to use the UNION keyword.

MySQL would still have to make three queries, but it would combine them into one result set.
Jun 22 '07 #4
seshu
156 100+
Thank you you have solved my problem and i can use this query and change many apps
thank you
Jun 22 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: 73blazer | last post by:
Hello, I'm looking for a SQL syntax to put a variable name into the from clause. Specifically I have a colume in a table that is table name, and I...
2
by: Andy S. | last post by:
Hi, I'm trying to declare and use temporary tables. I have written the following code in Java. Creating the tablespace (i can see the tablespace...
7
by: Gucci | last post by:
<?php /** * check ine year is a leap year, and return the month day array * * @param int $year **the year must bigger than zero** * @return...
1
by: Matik | last post by:
Hello Everybody, I have a problem, with select stmt: SELECT TOP 15 * FROM oaVIEW_MainData AS TOP_VIEW, oaLanguageData_TAB AS RwQualifierJoin...
0
by: jad2006 | last post by:
i created CREATE PROCEDURE SP_STMT_STMTRETRIEVE10(IN p_client_id varchar(32) ,IN p_TIN varchar(32)) P1: BEGIN DECLARE p_customer_id...
9
by: asenthil | last post by:
Hai to all,, i had to tried to retrive and write a single row to a file from the database.. But dont know to write all the retrived rows to a...
1
by: Kingsly | last post by:
How to read "stmt" column of "sysibm.syspackstmt" table in a readable format? select stmt from sysibm.syspackstmt where name like 'MYPROC1'; I...
5
by: andi | last post by:
Hello, I created a report in Acess2000 and now it repeats itself three times. At first I thought its a problem with the page margins but that...
8
by: yrrah | last post by:
Hello, i've a problem regarding the select stmt inside the stored procedure. Here's my code: DELIMITER $$ DROP PROCEDURE IF EXISTS...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.