I’m looking for the RIGHT way to query columns for match (got it working). But then there’s this-> AND the address column for match in which I would want only the title of that row returned. This would include ‘search by town’ within a keyword search. Pro ideas? And thanks!
//works!
SELECT * FROM beaches
WHERE title LIKE '%".$input."%'
//doesn't work at all
AND
SELECT title FROM address WHERE LIKE '%".$input."%'
UPDATE:
@LittleBobbyTables
That’s it! That is how you query multiple columns with a search query.
SELECT *
FROM beaches
WHERE (title LIKE '%".$input."%') OR (address LIKE '%".$input."%')
As for the other helpful answer I thought JOINS where for querying over TABLES, but what do I know? I couldn’t understand the single missing apostrophe. Thanks tho.
Since you need to include only the
titlecolumn from theaddresstable, then you need to useUNION:But the problem with this approach is that the columns returned by the first query needs to match the columns returned by the second query.