PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Joining search queries
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Joining search queries

Réponse
 
LinkBack Outils de la discussion
Vieux 17/09/2007, 22h22   #1
Alec
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Joining search queries

Sorry newbie question...

I have made two different search queries on the same table.

How can I join these together in one list, so the results from the
first query come listed before the second, ie keeping the same order.

Many thanks

Alec

  Réponse avec citation
Vieux 17/09/2007, 23h08   #2
Steve
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Joining search queries


"Alec" <ajtdds@aol.com> wrote in message
news:1190064167.203859.224910@19g2000hsx.googlegro ups.com...
> Sorry newbie question...
>
> I have made two different search queries on the same table.
>
> How can I join these together in one list, so the results from the
> first query come listed before the second, ie keeping the same order.


no telling since you post no code. in keeping...

select *
from
(
select 'a' source
'2' field
from foo
union
select 'b' source
'1' field
from foo
) derived
order by source


  Réponse avec citation
Vieux 18/09/2007, 09h21   #3
gosha bine
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Joining search queries

On 17.09.2007 23:22 Alec wrote:
> Sorry newbie question...
>
> I have made two different search queries on the same table.
>
> How can I join these together in one list, so the results from the
> first query come listed before the second, ie keeping the same order.


$results = array();

while($row = mysql_fetch_assoc($query_1))
$results[] = $row;

while($row = mysql_fetch_assoc($query_2))
$results[] = $row;


If this is not what you're looking for, please be more specific.



--
gosha bine

makrell ~ http://www.tagarga.com/blok/makrell
php done right http://code.google.com/p/pihipi
  Réponse avec citation
Vieux 18/09/2007, 12h07   #4
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Joining search queries

Alec wrote:
> Sorry newbie question...
>
> I have made two different search queries on the same table.
>
> How can I join these together in one list, so the results from the
> first query come listed before the second, ie keeping the same order.
>
> Many thanks
>
> Alec
>


Alec,

You should be asking SQL questions in a SQL group, not a PHP group.
You'll get much better answers.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  Réponse avec citation
Vieux 18/09/2007, 15h11   #5
Steve
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Joining search queries


"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
news:3budneICm_NOLHLbnZ2dnUVZ_tWtnZ2d@comcast.com. ..
> Alec wrote:
>> Sorry newbie question...
>>
>> I have made two different search queries on the same table.
>>
>> How can I join these together in one list, so the results from the
>> first query come listed before the second, ie keeping the same order.
>>
>> Many thanks
>>
>> Alec
>>

>
> Alec,
>
> You should be asking SQL questions in a SQL group, not a PHP group. You'll
> get much better answers.


that's debatable. ;^)


  Réponse avec citation
Vieux 18/09/2007, 17h51   #6
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Joining search queries

Steve wrote:
> "Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
> news:3budneICm_NOLHLbnZ2dnUVZ_tWtnZ2d@comcast.com. ..
>> Alec wrote:
>>> Sorry newbie question...
>>>
>>> I have made two different search queries on the same table.
>>>
>>> How can I join these together in one list, so the results from the
>>> first query come listed before the second, ie keeping the same order.
>>>
>>> Many thanks
>>>
>>> Alec
>>>

>> Alec,
>>
>> You should be asking SQL questions in a SQL group, not a PHP group. You'll
>> get much better answers.

>
> that's debatable. ;^)
>
>


Not at all. There are a number of possibilities here, none of which I
have seen offered in this group. But I've seen a lot of them offered in
comp.databases.mysql.

People here are PHP experts. People in comp.databases.mysql are MySQL
experts - and have vastly more knowledge about MySQL than most PHP
programmers.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  Réponse avec citation
Vieux 18/09/2007, 18h26   #7
Steve
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Joining search queries


"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
news:q66dndxLtZMJn23bnZ2dnUVZ_gSdnZ2d@comcast.com. ..
> Steve wrote:
>> "Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
>> news:3budneICm_NOLHLbnZ2dnUVZ_tWtnZ2d@comcast.com. ..
>>> Alec wrote:
>>>> Sorry newbie question...
>>>>
>>>> I have made two different search queries on the same table.
>>>>
>>>> How can I join these together in one list, so the results from the
>>>> first query come listed before the second, ie keeping the same order.
>>>>
>>>> Many thanks
>>>>
>>>> Alec
>>>>
>>> Alec,
>>>
>>> You should be asking SQL questions in a SQL group, not a PHP group.
>>> You'll get much better answers.

>>
>> that's debatable. ;^)

>
> Not at all. There are a number of possibilities here, none of which I
> have seen offered in this group. But I've seen a lot of them offered in
> comp.databases.mysql.
>
> People here are PHP experts. People in comp.databases.mysql are MySQL
> experts - and have vastly more knowledge about MySQL than most PHP
> programmers.


well, i am a participant in both as most others here are. if he gives us an
idea of what he's wanting to do, i guarantee he'll get an expert response
from me. ;^)


  Réponse avec citation
Vieux 08/10/2007, 14h20   #8
Alec
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Joining search queries

On 18 Sep, 10:21, gosha bine <stereof...@gmail.com> wrote:
> On 17.09.2007 23:22Alecwrote:
>
> > Sorry newbie question...

>
> > I have made two different search queries on the same table.

>
> > How can Ijointhese together in one list, so the results from the
> > first query come listed before the second, ie keeping the same order.

>
> $results = array();
>
> while($row = mysql_fetch_assoc($query_1))
> $results[] = $row;
>
> while($row = mysql_fetch_assoc($query_2))
> $results[] = $row;
>
> If this is not what you're looking for, please be more specific.
>
> --
> gosha bine
>
> makrell ~http://www.tagarga.com/blok/makrell
> php done right http://code.google.com/p/pihipi


Gosha

Thanks for the and sorry for the delay in a reply.

Sadly I have tried the SQL group today but with no joy.

To be more specific about the problem, I have made two different
search queries on the same table that both
retain the identical column information.


$resultfirst = @mysql_query ("SELECT company, address1, address2 FROM
table1 WHERE category=active ")


$resultsecond = @mysql_query ("SELECT company, address1, address2
FROM
table1 WHERE category=inactive ")


How can I now join these together in one list, with the results from
the first query being listed before the second, ie keeping the same
order.


Many thanks


Alec Thorne


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h32.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,16165 seconds with 16 queries