[thelist] SQL Query

rudy rudy937 at rogers.com
Mon Aug 18 12:58:55 CDT 2003


> Select just the two-dot values:
>
>   SELECT * from mytable WHERE myfield LIKE "%.%.%"
>     AND NOT myfield LIKE "%.%.%.%"

good thinking, dougal, but try your query on some test data like this --

  1.onedot
  2.two.dots
  3...threedotsinarow
  4.four.dots.oops.i.lied.theres.more
  2.22.222.a.lot.of.dots.in.this.one.too

i like tab's solution -- very elegant -- although it does depend on a
REPLACE function which maybe not every database has

i'm sure there's a regex solution to the original problem but few databases
support regular expressions in sql

mysql being one that does   ;o)

rudy




More information about the thelist mailing list