Posted By

powerthru on 10/13/10


Tagged

match substring lcv ballots


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


find one string inside another string, comparing two columns


 / Published in: SQL
 

in this case, we wanted to match fields where the district field in table b contained things like "LAM2-OUTSIDETOWN" and we wanted to match that to fields in table a which only had "LAM2" in them. "INSTR" ("in string") is our friend:

  1. SELECT a.first, a.last, a.district, a.zip, b.zip, b.first, b.last, b.district
  2. FROM clerk_ballots a, lcv_members b
  3. WHERE a.first LIKE b.first
  4. AND b.last LIKE a.last
  5. AND INSTR(b.district, a.district)

Report this snippet  

You need to login to post a comment.