Author Topic: SQL: query for non-alphanumerics  (Read 2138 times)

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
SQL: query for non-alphanumerics
« on: April 17, 2011, 10:38:28 PM »
How do you query for values that are not alphanumeric?  One of my users uploaded a file and I never got around to restricting the input to alphanumeric and now there is a bunch of gibberish shit in the database.  Help.

I fucking hate this shit.

Mike

  • Jackass In Charge
  • Posts: 11257
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: SQL: query for non-alphanumerics
« Reply #1 on: April 17, 2011, 11:12:18 PM »
How do you query for values that are not alphanumeric?  One of my users uploaded a file and I never got around to restricting the input to alphanumeric and now there is a bunch of gibberish shit in the database.  Help.

I fucking hate this shit.
So you are looking for any row that doesn't contain alphanumeric characters?

Maybe something like
Code: [Select]
SELECT foo
FROM bar
WHERE baz REGEXP '[^A-Za-z0-9 ]'

You can add in any other symbols you do want to allow.

Do you know what type of files they uploaded?  Might be easier to search for the identifying parts of those files.

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: SQL: query for non-alphanumerics
« Reply #2 on: April 18, 2011, 08:16:13 AM »
Why didn't you just restrict the input while you were doing it?
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: SQL: query for non-alphanumerics
« Reply #3 on: April 18, 2011, 08:28:17 AM »
Thanks Mike, I'll try that.  They're supposed to be very basic CSV files.  It appears as though he might be uploading some Excel files though based on some of what is ending up in the DB.  At least I can identify the file being uploaded because he has to select a specific company before uploading.

Steve, because I'm lazy and it's one person uploading a few dozen files and I didn't think he could fuck it up.

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: SQL: query for non-alphanumerics
« Reply #4 on: April 18, 2011, 08:33:23 AM »
That worked Mike.  I didn't realize you could do REGEX in SQL WHERE clauses.

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: SQL: query for non-alphanumerics
« Reply #5 on: April 18, 2011, 08:54:13 AM »
....one person........ uploading a few dozen files and I didn't think he could fuck it up.

How long have you been doing this??? :rofl2:
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?