简体   繁体   中英

proper way of using OR inside sql statement

I'm using dapper micro orm in conjuction with sql server .

 string author = "some author name";
 var get_book_from_name = "SELECT BookId FROM Author WHERE FirstName OR LastName LIKE('%' +@AuthorName +'%')";
 var data = this.db.Query<Book>(getBookFromAuthorName, new { AuthorName = author }).SingleOrDefault();

and I'm getting error using OR statement in query statement.

SELECT BookId FROM Author WHERE
    FirstName LIKE '%'+@AuthorName+'%' OR LastName LIKE '%'+@AuthorName+'%'

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM