You are here: Re: Joining search queries « PHP Programming Language « IT news, forums, messages
Re: Joining search queries

Posted by Jerry Stuckle on 10/08/07 20:51

Alec wrote:
> Newbie question.
>
> Its really an SQL question, but have had no reply from the SQL
> newsgroup.
>
> I want to search the same table for two different criteria, and then
> join the search results together into one new list. See below.
>
> <?php
>
> $result = @mysql_query ("SELECT company, priority FROM table1 WHERE
> priority ='high' "); UNION; @mysql_query ("SELECT company, priority
> FROM table1 WHERE priority ='low' ");
>
> while ($row = mysql_fetch_array($result))
>
> {
>
> $company = $row['company']; echo $company;
> $priority = $row['priority']; echo $priority;
>
> }
> ?>
>
> BUT it only returns the first search result, even though there are
> records that relate to the second.
>
> What am I doing wrong? Also can UNION be used to combine more than two
> searches?
>
> Many thanks
>
> Alec
>

Where did you ask? I didn't see it in comp.databases.mysql, which is
where you should be asking.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

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

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