Avatar of joomla
joomla
Flag for Australia asked on

search an sql database

Table 'people'
columns 'username','customfield','customvalue'
Table 'custom-fields'
columns 'fieldID','fieldName'

Data in 'people' table
joe, 2,small
joe,3,black
joe,4,deaf
pat,2,small
pat,3,brown
pat,4,blind
lisa,2,big
lisa,4,blind
alex,2,medium
alex,3,white
alex,4,deaf

Data in 'customfields' table
1,gender
2,size
3,color
4,handicap

I want to get a subset that finds all people who have the handicap of being 'blind' and returns all data about them

ie
pat,2,small
pat,3,brown
pat,4,blind
lisa,2,big
lisa,4,blind

select * from people p left join customfields on p.customfield = c.fieldID where c.fieldID=4 and p.customvalue="blind"

This finds
pat,4,blind
lisa,4,blind

how do I get the more complete list
MySQL Server

Avatar of undefined
Last Comment
joomla

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
johanntagle

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
BuggyCoder

select * from people a inner join customfields b on a.customfield=b.fieldid where b.fieldid=4 and p.customvalue='blind'

Open in new window

joomla

ASKER
thank you
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy