find one string inside another string, comparing two columns


/ Published in: SQL
Save to your folder(s)

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:


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.