Skip to main content
Known Participant
January 14, 2011
Question

Search for a record by number

  • January 14, 2011
  • 1 reply
  • 309 views

I've created two search fields.

Search field 1 - Search by entering a city name (or a partial city name) - this works fine. (I am using the 'colname3' variable for this).

Search field 2 - I want the user to search by number with an exact match, e.g. they enter '123456' to return record '123456' from the database.

I can't seem to get this to work properly, at the moment I'm using the 'colname3' variable below which returns partial results e.g. '123' returns result '123456'.

How can I modify this so the user has to enter the exact number to return the required result?

This is the variable I'm using:

Name:colname3

Type: text

Default value: -1

Runtime value: $_GET['jobnumberfield']

This is the SQL statement:

SELECT *
FROM joinversion3
WHERE job_no LIKE %colname3%

This topic has been closed for replies.

1 reply

January 14, 2011

For exact match use = argument instead of LIKE argument. Setup conditional statement where if LIKE form is submitted then run LIKE query elseif exact match form is submitted run exact match query.

SELECT *

FROM joinversion3

WHERE job_no = $colname3

Wookie1Author
Known Participant
January 17, 2011

Hi,

Thanks for that. I'm doing this through the advanced recordset dialogue box in DW. Can you advise me how to write the conditional statement and where it should be placed in the code?

Thanks