Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Query to find matching values based on user input
    primarykey
    data
    text
    <p>I'm building a website for property agents and tenants. Tenants can sign up and fill in their desired locations for properties, including Street, Town and Postcode. Once they sign up, this automatically emails agents who have properties that match those search criteria.</p> <p>At present I have the query set up as follows so that it matches on either the Street, Town or Postcode.</p> <pre><code>&lt;% Dim rspropertyresults Dim rspropertyresults_numRows Set rspropertyresults = Server.CreateObject("ADODB.Recordset") rspropertyresults.ActiveConnection = MM_dbconn_STRING rspropertyresults.Source = "SELECT * FROM VWTenantPropertiesResults " 'WHERE (ContentStreet = 'Holderness Road') OR (ContentTown = 'Hull') OR (ContentPostCode = 'HU') rspropertyresults.Source = rspropertyresults.Source&amp; "WHERE (ContentStreet = '" &amp; Replace(rspropertyresults__varReqStreet, "'", "''") &amp; "'" rspropertyresults.Source = rspropertyresults.Source&amp; "OR ContentTown = '" &amp; Replace(rspropertyresults__varReqTown, "'", "''") &amp; "' " rspropertyresults.Source = rspropertyresults.Source&amp; "OR ContentTrimmedPostCode = '" &amp; Replace(varPostcode, "'", "''") &amp; "' ) " rspropertyresults.Source = rspropertyresults.Source&amp; "AND (( ContentBedRooms &gt;= " &amp; Replace(rspropertyresults__varBedroomsNoMin, "'", "''") &amp; " " rspropertyresults.Source = rspropertyresults.Source&amp; "AND ContentBedRooms &lt;= " &amp; Replace(rspropertyresults__varBedroomsNoMax, "'", "''") &amp; " ) " rspropertyresults.Source = rspropertyresults.Source&amp; "AND ( ContentPrice &gt; = " &amp; Replace(rspropertyresults__varPriceMin, "'", "''") &amp; " " rspropertyresults.Source = rspropertyresults.Source&amp; "AND ContentPrice &lt;= " &amp; Replace(rspropertyresults__varPriceMax, "'", "''") &amp; " )) " &amp; varSQL &amp; " " rspropertyresults.Source = rspropertyresults.Source&amp; "ORDER BY ContentPrice " &amp; Replace(rspropertyresults__varSortWay, "'", "''") &amp; " " rspropertyresults.CursorType = 0 rspropertyresults.CursorLocation = 2 rspropertyresults.LockType = 1 rspropertyresults.Open() rspropertyresults_numRows = 0 %&gt; </code></pre> <p>However, the client has asked that instead of just matching on one of the values, it needs to work in such a way that if say Street and Town match, then email that property agent or if Town and Postcode match, then email that property agent.</p> <p>As you can imagine, I think the query would become quite complex, but i'm unsure how to best design a query like this.</p> <p>I wondered if anyone might be able to help or point me in the right direction?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload