You are here: Re: how to have these two consequent queries become a single one by 'join' in mysql « PHP Programming Language « IT news, forums, messages
Re: how to have these two consequent queries become a single one by 'join' in mysql

Posted by nice.guy.nige on 07/22/07 18:58

While the city slept, newbie (mitbbsmj@yahoo.com) feverishly typed...

[...]

> $result= mysql_query(" select * from table_info where first_name =
> 'tom' ");
> $id = $result['id'];
> mysql_query(" select * from table_working_hr where id='$id' AND
> coming_date > 20 ");
>
> Can I get the result with a single query (with some advanced query
> like join )?

mysql_query("select twh.* from `table_working_hr` twh inner join
`table_info` ti on twh.id = ti.id where ti.first_name = 'tom' and
twh.coming_date > 20");

Hope that helps,
Nige

--
Nigel Moss http://www.nigenet.org.uk
Mail address will bounce. nigel@DOG.nigenet.org.uk | Take the DOG. out!
"Your mother ate my dog!", "Not all of him!"

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация