Replace in SQL statement

Results 1 to 2 of 2

Thread: Replace in SQL statement

  1. #1
    Join Date
    Dec 1969

    Default Replace in SQL statement

    Sorry, but I need to ask this again.<BR><BR>I&#039m using Access and I&#039m trying to write a query statment that searches a database of social security numbers (they all have hyphens) to see if one matches what a user puts into a form. Since the user may put in their SSN with or without hyphens, the query must take that into account. <BR><BR>This isn&#039t right I know, but any ideas how to make it work? <BR><BR>Query = "Select * from tablename where replace(SSN,&#039-&#039,&#039&#039)=" & Replace(request.form("password"),"-","") <BR><BR>Any help would be appreciated. Thanks.

  2. #2 Guest

    Default Simple: Your criterion needs quotes!

    Query = "Select * from tablename where replace(SSN,&#039-&#039,&#039&#039)=&#039" & Replace(request.form("password"),"-","") & "&#039"<BR><BR>but put a write statement after the line to see that the sql is correct:<BR><BR>Response.Write "<BR>" & Query & "<BR>"<BR><BR>Some dialects of SQL may not support replace function.<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts