[thelist] mysql question

Means, Eric D eric.d.means at boeing.com
Wed Oct 16 12:53:01 CDT 2002


-----Original Message-----
From: Kevin [mailto:lists at irubin.com]
Sent: Wednesday, October 16, 2002 12:45 PM
To: Thelist
Subject: Re: [thelist] mysql question

> > > Can these be combined to return results from both tables?
> >
> > select item_id from tableA WHERE item_review='$search_term';
> > union
> > select item_id from tableB WHERE description='$search_term';
>
> Is there an alternative that can be used for mysql 3.x

Sorry, wasn't paying close enough attention.



create temporary table temp (
  item_id INTEGER
}

insert into temp (item_id)
select item_id from tableA WHERE item_review='$search_term'

insert into temp (item_id)
select item_id from tableB WHERE description='$search_term'

select distinct item_id from tableB

drop table temp


It might turn out, however, to be easier to just do it in two different
normal queries and retrieve two recordsets, then combine the two on the
client side (since you'll presumably be stepping through the records
anyway).



More information about the thelist mailing list