Hello,
I am creating a search function and would like this two work with 2 or more tables; Dog Catalog and portfolio in this example. What am I doing wrong here?
"SELECT * FROM portfolio, Dog Catalog WHERE
Dog Catalog.title LIKE '%$find%' or
portfolio.client LIKE '%$find%'";
I get errors whenever I try to echo a result.
Any help would be appreciated.
Select from 2 different tables
Moderator: General Moderators
Re: Select from 2 different tables
you need to use a join: http://www.w3schools.com/SQl/sql_join.asp
That should work with your keys in. But read up on joins first so you have more of an idea at whats going on 
Code: Select all
"SELECT * FROM portfolio, Dog Catalog WHERE
Dog Catalog.title LIKE '%$find%' or
portfolio.client LIKE '%$find%'";Code: Select all
SELECT *
FROM portfolio
INNER JOIN Dog Catalog
ON portfolio.column_name = Dog Catalog.column_name (needs to be the PK and FK)
WHERE Dog Catalog.title LIKE '%$find%' or
portfolio.client LIKE '%$find%'