You are here: Re: dealing with more than 1 table « PHP SQL « IT news, forums, messages
Re: dealing with more than 1 table

Posted by Sean on 11/28/06 13:19

"Brian" <not@given.com> wrote in message
news:tdCah.22442$0x.5146@newsfe1-win.ntli.net...
> Hi there
>
> I am trying to write the follwoing statement in the best way possible
> in a PHP page. I think i need to use a join somewhere but i always
> get confused with them, also trying to work out if it can be done
> without using a loop from the first search
>
> I have 3 tables,
> T1
> T2
> T3
>
> T1 and T2 have the same structure but just called different names
>
> User inputs a "search"
>
> SELECT `ACol` FROM `T1` WHERE `T1ACol` = "search" < this may bring back
> more than 1 result
>
> Now
>
> SELECT `FieldA`, `FieldB`, `FieldC` (< Fields A,B,C from both T2 and T3)
> FROM `T2`,`T3`
> WHERE T2ACol = the above results
> OR
> T3ACol = the above results
>
> Thanks
>
> Brian
>
>

Try:

SELECT *
FROM T2, T3
WHERE T2ACol IN (SELECT ACol FROM T1 WHERE T1ACol = 'search')
OR T2ACol IN (SELECT ACol FROM T1 WHERE T1ACol = 'search')

 

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

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