You can use SQL's UNION, which lets you join the results of more than
one query into a single resultset. Eg:
CREATE TABLE test1 (
blah varchar(255) default NULL
) ;
CREATE TABLE test2 (
blah varchar(255) default NULL
) ;
INSERT INTO test1 (blah) VALUES ('bar');
INSERT INTO test2 (blah) VALUES ('foo');
SELECT *
FROM test1
WHERE blah IN ( 'foo', 'bar' )
UNION
SELECT *
FROM test2
WHERE blah in ( 'foo', 'bar' ) ;
+------+
| blah |
+------+
| bar |
| foo |
+------+
2 rows in set (0.01 sec)
On Thu, Jan 8, 2009 at 12:41 AM, Michael <[email protected]> wrote:
>
> I have the following select statement-
>
> $sql1 = mysqli_query($link,"SELECT id FROM $tblname1 WHERE
> $tblfield='".strtolower($result)."'")
> or die ('Error: Query 1 failed');
>
> I want to run it on 2 identical tables to see if $result exists in either.
>
> How is this done in one statement?
>
> Michael
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---