mardi 2 juin 2015

Sqlite query to determine gender by first name

I have 2 sqlite3 tables : FND is a Table of names and their likely gender i.e.:

nm,gndr  <-column names
Aliyah,F
Moses,M
Peter,M

Members is second table i.e.

Fname,Lname    <-column names
DAVID X, BAKER
MARY MIA,MCGEE
TINA HEATHER,JOHNSON
JIM PETER TOM, SANTINO 

The members table has first and middle names in the fname column.

I am trying to write a query to list the Members table fnames column, with a generated column indicating gender based on the first word in the fname column.

I tried this but it didn't work:

select m.fname,(select gndr from FND where upper(nm) like m.fname||'%')as gender
from Members m

can anyone correct my sql statement?

Aucun commentaire:

Enregistrer un commentaire