FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Help.Nested Quarey in MySqL





chatrack
Hellow,
I have Two tables in a database.

Here table1 have fields id, first_name, last_name

and another table2 have fields id, track_no

I want to get the first_name of those id's whose track_no is provided, I think this can be done
by nested quarey... Confused but i could not work it out yet... can you help..
Manofgames
http://www.tizag.com/mysqlTutorial/mysqljoins.php
leontius
Code:
SELECT table1.first_name FROM table1 INNER JOIN table2 ON table1.id = table2.id WHERE table2.track_no = $constant


Or if you insist on nested query:

Code:
SELECT table1.first_name FROM table1 INNER JOIN (SELECT id FROM table2 WHERE track_no = $constant) t2 ON table1.id = t2.id


(sorry if there's syntax error but it should be conceptually correct)
chatrack
Hi Manofgames,

I have gone through the links, and got a solution. It is just like this

$sql = "SELECT DISTINCT table1.first_name, table2.id FROM tabel1, table2 WHERE table2.id = $thisid";

THANKS for quick replys and Guidence.
Related topics
Help me with MySQL Account Maintenance and phpBB 2.0.15 :((
MYSql
mysql/php help please
Help Installing MySQL on SuSE Linux using ssh
Help on Backing up MySQL Databases
MySQL SUBselect queries and Nested queries
Help with mysql query
Need help understanding MySQL "Resource" type retu
Please help.....Flash, PHp, MySql
Problem with MySQL Server Please Help!!
HELP on PHP MYSQL : everything MESSED UP
Need Expert help in php-mysql
help - Problemas con mysql
PHP issues >.>
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.