I\'m bulding a search function for my web site and wish to search by two columns: title and author.
Query:
SELECT title, bookID, publisher, pubDate, boo
SELECT title, bookID, publisher, pubDate, book_image, books.authorID, authors.author
FROM books, authors
WHERE books.authorID = authors.authorID
AND (title LIKE '$queryString%' OR author LIKE '$queryString%')LIMIT 5
this should do the work
Try it out:
SELECT bk.title, bk.bookID, bk.publisher, bk.pubDate, bk.book_image, bk.authorID, au.author
FROM books bk, authors au
WHERE bk.authorID = au.authorID AND bk.title LIKE '$queryString%' OR au.author LIKE '$queryString%' LIMIT 5
Try below :
SELECT title, bookID, publisher, pubDate, book_image, books.authorID, authors.author
FROM books left join authors on books.authorID = authors.authorID
WHERE (title LIKE '$queryString%' OR author LIKE '$queryString%') LIMIT 5
I would like to suggest you to use fulltext search in mysql.That will be more faster and efficient