| | |
Help...! (Sub Query)
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
hi to all,
this might be very simple, but i don;t know how to get correct output, someone help me to complete it...
1st i need to get result from this query
this'll result either all the boys or all the girls;
from the above result again i need select according to their age using this 2nd query.
Help me to do this in single subquery...
Thanx in advance...
this might be very simple, but i don;t know how to get correct output, someone help me to complete it...
1st i need to get result from this query
MySQL Syntax (Toggle Plain Text)
$sql="SELECT * FROM $tbl1_name WHERE sex='$show_all'"; $result=mysql_query($sql);
from the above result again i need select according to their age using this 2nd query.
MySQL Syntax (Toggle Plain Text)
$sql="SELECT * FROM $tbl1_name WHERE age BETWEEN '$from' AND '$to'"; $result=mysql_query($sql);
Help me to do this in single subquery...
Thanx in advance...
Last edited by Ezzaral; Oct 7th, 2009 at 7:03 pm. Reason: Added [code] [/code] tags. Please use them to format any code that you post.
0
#2 Oct 8th, 2009
php Syntax (Toggle Plain Text)
$sql="SELECT * FROM $tbl1_name WHERE sex='$show_all' AND age BETWEEN '$from' AND '$to'";
"If it is NOT source, it is NOT software."
-- NASA
-- NASA
•
•
Join Date: Apr 2009
Posts: 47
Reputation:
Solved Threads: 10
0
#4 Oct 8th, 2009
SQL Syntax (Toggle Plain Text)
SELECT * FROM $tbl1_name WHERE age BETWEEN '$from' AND '$to' AND sex='$show_all'
Last edited by peter_budo; Oct 13th, 2009 at 5:10 am. Reason: Correcting code tags
0
#6 Oct 8th, 2009
i done like this,
I knew it is not better than yours, Pritaeas...
is it right way?
MySQL Syntax (Toggle Plain Text)
$sql="SELECT * FROM $tbl1_name WHERE username='$name' IN (SELECT * FROM $tbl1_name WHERE sex=$sex01)"; $result=mysql_query($sql);
I knew it is not better than yours, Pritaeas...
is it right way?
•
•
Join Date: Sep 2009
Posts: 527
Reputation:
Solved Threads: 61
0
#9 Oct 9th, 2009
why to complicate the simple query, he just have two simple reuirements on the same table as -
1)age BETWEEN something AND something
and 2)sex as all on same table
It aslo depends upon what you pass as in $from and $to
1)age BETWEEN something AND something
and 2)sex as all on same table
MySQL Syntax (Toggle Plain Text)
SELECT * FROM $tbl1_name WHERE sex='$show_all and age BETWEEN '$from' AND '$to'
![]() |
Similar Threads
- Sql Query (VB.NET)
- Removing Query Strings (ASP.NET)
- Double MySQL Query (PHP)
- Dynamic Query (JSP)
- MySQL nested query / joined query conversion help (MySQL)
- problem with lengthy query (Java)
- Retreiving variables from a sql query into a form (PHP)
- Query Building (Database Design)
Other Threads in the MySQL Forum
- Previous Thread: Trouble using ORDER BY in a UNION statement
- Next Thread: INSERT with if function help please
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire laptop law legal license licensing linux maintenance managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opensource oracle penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency





