How do you use the MySql IN clause

后端 未结 3 636
梦毁少年i
梦毁少年i 2020-12-21 09:05

I am trying to figure out how to use the MySql In cluse with ASP.NET C#. Here is my code

var WebSites = string.Join(\",\", wsl.Select(x => \"\'\" + x.Doma         


        
3条回答
  •  长情又很酷
    2020-12-21 09:31

    The IN statement should expect an Array of strings, and you are passing a single string

    Your final SQL is looking like this:

    select Id, Url, Title, Date, ImageUrl from post where WebSiteUrl IN ('url1,url2,url3')
    

    Instead of

    select Id, Url, Title, Date, ImageUrl from post where WebSiteUrl IN ('url1', 'url2', 'url3')
    

    Check this question:

    Add List to a mysql parameter

提交回复
热议问题