I have two tables I need to select * from
. Im building a search code.
This is my query:
SELECT articles.*, news.* FROM articles, news WHERE title LIKE '%$search%' OR short_description LIKE '%$search%' OR author LIKE '%$search%' OR date LIKE '%$search%' LIMIT 15
I get this error:
Error
SQL query: Documentation
SELECT articles.*, news.* FROM articles, news WHERE title LIKE '%$search%' OR short_description LIKE '%$search%' OR author LIKE '%$search%' OR date LIKE '%$search%' LIMIT 15
MySQL said: Documentation
#1052 - Column 'title' in where clause is ambiguous
Try this?
SELECT a.*, n.* FROM articles a,
join news n on a.____ = n.______
WHERE a.title LIKE '%$search%' OR a.short_description LIKE '%$search%'
OR n.author LIKE '%$search%' OR n.date LIKE '%$search%'
LIMIT 15
You need to add Alias', I have guessed below what each of the tables the LIKE statements could be pulling from. You'll need to replace the a.___ with the right identifier yourself.
It may also be worth changing the old JOIN Syntax.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.