Forum Moderators: coopster
$query = "select * from names where product like \"%$trimmed%\"
what I would like to do is not only have it search a table called "names" but also "stores" as well for the "product" field.
I don't have server access at the moment to test it but would it just have to be something like
$query = "select * from names,stores where product like \"%$trimmed%\"
or is something else needed?
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource error for the bottom line
$query = "SELECT *
FROM name AS a,
stores AS b
WHERE
a.product LIKE \"%$trimmed%\"
OR
b.product LIKE \"%$trimmed%\"
order by product";
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
I use PostgreSQL primarily and, I believe, that query is syntactically correct for Postgres.
I noticed you replaced my ' with ", try it with '.
The basic syntax of the query is sound.
Cheers,
BAD
test=# create table name(
test(# product text
test(# );
CREATE TABLE
test=# insert into stores (product) values ('widget');
INSERT 17627 1
test=# insert into name (product) values ('big blue widget');
INSERT 17628 1
test=# select * from name AS a, stores AS b where a.product like '%widget%' or b.product like '%widget%' order by product;
ERROR: ORDER BY "product" is ambiguous
test=# select * from name AS a, stores AS b where a.product like '%widget%' or b.product like '%widget%' order by a.product;
product ¦ product
-----------------+---------
big blue widget ¦ widget
(1 row)
Quick test works here, sorry.
BAD