bluewaves Posted May 25, 2007 Share Posted May 25, 2007 What is the format for selecting one word from a Name Column? Example: Column=Name Name=Sterling Silver Three Pronged Fork I want to pick products that say "fork" in the name. Quote Link to comment https://forums.phpfreaks.com/topic/52983-sql-query-that-selects-one-word-from-a-column-many-words/ Share on other sites More sharing options...
o3d Posted May 30, 2007 Share Posted May 30, 2007 You can use charindex for ms sql. You specify what your looking for as the first parameter and the string that you are searching in as the second parameter. If the first parameter exists in the second parameter, it will return the index where the string starts in the second parameter, else it will return 0 if not found in the second parameter. e.g. CHARINDEX('cc', 'aa bb cc dd') will return 7 where as CHARINDEX('ee', 'aa bb cc dd') will return 0. Quote Link to comment https://forums.phpfreaks.com/topic/52983-sql-query-that-selects-one-word-from-a-column-many-words/#findComment-264506 Share on other sites More sharing options...
anders Posted May 30, 2007 Share Posted May 30, 2007 Hi. Do this work in mssql? select * from tablename where Name like '%fork%' Quote Link to comment https://forums.phpfreaks.com/topic/52983-sql-query-that-selects-one-word-from-a-column-many-words/#findComment-264508 Share on other sites More sharing options...
bluewaves Posted May 30, 2007 Author Share Posted May 30, 2007 Thank you. I'll try that. Quote Link to comment https://forums.phpfreaks.com/topic/52983-sql-query-that-selects-one-word-from-a-column-many-words/#findComment-264912 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.