开发者

query builder of Visual Studio 2008 with mySQL

开发者 https://www.devze.com 2022-12-20 15:09 出处:网络
I am trying to filter my results in the query builder of Visual Studio 2008 so that when it executes the query to SELECT data from the field i chose, it will only retrieve last names that start with a

I am trying to filter my results in the query builder of Visual Studio 2008 so that when it executes the query to SELECT data from the field i chose, it will only retrieve last names that start with an user input. I figure this is to be done using the filter tab. SO i put a filter I used different filters but did not work with me. I'm using mySQL database.

here is the code I used:

SELECT Last_Name FROM 开发者_运维知识库 contact_info WHERE (Last_Name LIKE 'prefixText%') will return null ........ SELECT Last_Name FROM contact_info WHERE (Last_Name LIKE @prefixText%) will give me error ............ SELECT Last_Name FROM contact_info WHERE (Last_Name LIKE '@prefixText%')will return null ................ SELECT Last_Name FROM contact_info WHERE (Last_Name LIKE @prefixText)will return null ............................

here is the error I'm getting: [URL=http://img180.imageshack.us/i/errorm.jpg/][IMG]http://img180.imageshack.us/img180/8983/errorm.jpg[/IMG][/URL] please advice what is the correct syntax for mySQL to use in query builder of Visual Studio 2008 to return fields start with first letter that the user enter???


this code work OK for me.

SELECT First_Name FROM contact_info WHERE (First_Name LIKE CONCAT(@prefixText, '%'))


If @prefixText is a parameter then try..

SELECT Last_Name FROM contact_info WHERE Last_Name LIKE '%'+@prefixText+'%';

LIKE Operator

0

精彩评论

暂无评论...
验证码 换一张
取 消