Charity Posted May 6, 2015 Posted May 6, 2015 Here is what I need. I have global field called gColorized. How would I write this, please? Select ProductNumber from Products where ProductDescription contains value in Globals::gColorized or where Refactor contains value in gColorized Everything I've tried, I only get ? Thank you for helping. SQL does not like me yet.
eos Posted May 6, 2015 Posted May 6, 2015 (edited) Well, I am posting to have fun, which puzzle solving is … So relax a little, and try ExecuteSQL ( " SELECT ProductNumber FROM Products WHERE ProductDescription LIKE '%" & Globals::gColorized & "%' OR Refactor LIKE '%" & Globals::gColorized & "%' " ; "" ; "") which thanks to LIKE and the % placeholder works like PatternCount(), i.e. matches on substrings; depending on your need, you may want to work with Lower() or Upper() (same function names in both FM and SQL) to find case-insensitive matches. Note that you cannot use FM syntax in/as SQL references; i.e. a fully qualified field name in FM is TableName::fieldName, but in SQL its TableName.fieldname.But as long as the table reference is unambiguous (which in simple queries it usually is), you don't have to use that form anyway. Since you have Advanced, you could also put the Data Viewer to good use and try Let ( sql = "SELECT ProductNumber FROM Products WHERE ProductDescription LIKE '%" & Globals::gColorized & "%' OR Refactor = '%" & Globals::gColorized & "%' " ; Execute ( sql ; "" ; "" ) // sql ; switch commented expressions, i.e. use sql // Execute ( sql ; "" ; "" ), to quickly see and examine the literal sql string (and spot errors)) to aid in debugging. Edited May 6, 2015 by eos 2
Charity Posted May 6, 2015 Author Posted May 6, 2015 (edited) Okay I have mellowed. Thank you for helping me Eos. This is exactly what I needed. and the tip on data viewer with SQL helps also. Edited May 6, 2015 by Charity
Recommended Posts
This topic is 3565 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now