Mysql search query two columns

前端 未结 3 1076
悲哀的现实
悲哀的现实 2021-01-24 10:40

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         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-24 11:02

    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
    

提交回复
热议问题