Using the LIKE keyword in a query
-
Hey, I'm using this database through MS Access with my program and I need to be able to use the LIKE keyword. My forms have specific, formatted field names that are sequential and uniform. Essentially, the first part of every form field name is a part of its subsequential heading. IE. I have a 'heading' column in my table, 'paragraphs'. One example of my headings is 'Scope of Services & Workplan/Methodology Overview'. Now, if I were to use a query searching for that exact name everything works fine. However, I need to use the LIKE clause as follows: SELECT heading FROM paragraphs WHERE heading LIKE 'Scope%' This is because the first part of my form fields are the first words of every heading. ie. Scope_1_chbx, Scope_2_chbx, and so on. My LIKE clause is resulting in the query returning no results....can anyone help me? Thanks. --- reegan41
-
Hey, I'm using this database through MS Access with my program and I need to be able to use the LIKE keyword. My forms have specific, formatted field names that are sequential and uniform. Essentially, the first part of every form field name is a part of its subsequential heading. IE. I have a 'heading' column in my table, 'paragraphs'. One example of my headings is 'Scope of Services & Workplan/Methodology Overview'. Now, if I were to use a query searching for that exact name everything works fine. However, I need to use the LIKE clause as follows: SELECT heading FROM paragraphs WHERE heading LIKE 'Scope%' This is because the first part of my form fields are the first words of every heading. ie. Scope_1_chbx, Scope_2_chbx, and so on. My LIKE clause is resulting in the query returning no results....can anyone help me? Thanks. --- reegan41
Your select statement looks okay to me. Perhaps your data is the problem. I've had problems with the LIKE feature because of selecting LIKE 'ABC%' when my data was in lower case, LIKE 'abc%'. If that is not the case, could you please explain what you are doing further? What do you mean with the Scope_1_chbx, Scope_2_chbx stuff? Could you give us some actual data from the tables? Hope this helps.
-
Your select statement looks okay to me. Perhaps your data is the problem. I've had problems with the LIKE feature because of selecting LIKE 'ABC%' when my data was in lower case, LIKE 'abc%'. If that is not the case, could you please explain what you are doing further? What do you mean with the Scope_1_chbx, Scope_2_chbx stuff? Could you give us some actual data from the tables? Hope this helps.
-
I actually figured it out...believe it or not, it was because I was using LIKE 'data%' instead of LIKE "data*" For some reason THAT worked instead...odd, but thanks for your help regardless