Since you are self-declared newbie, what I'm about to say might not make sense at first glance. But if you try to read and understand it, you'll be moving forward from newbiehood into good design.
What you want is 2 tables.
Table 1 would be something like "BaseRecord"
Table 2 would be something like "RecordAttribute"
Each BaseRecord would have one more associated Record Attribute
Layout is pretty simple:
BaseRecord
id (integer(5), auto_increment)
That's all that's needed for the scheme to work. BUT you might add more fields:
BaseRecord
id (integer(5), auto_increment)
name(varchar(200))
etc
RecordAttribute
id (integer(6), auto_increment)
BaseRecordId (foreign Key)
AttributeType (varchar(200))
AttributeValue (varchar(200))
HEre's how it works
Create base record 1
INSERT INTO BaseRecord SET id=1, name='Alan Davis'
Now create the RecordAttribute data:
INSERT INTO RecordAttribute
SET id=NULL,
BaseRecordId=1,
AttributeType='Eyes',
AttributeValue='Blue';
INSERT INTO RecordAttribute
SET id=NULL,
BaseRecordId=1,
AttributeType='Eyes',
AttributeValue='Green';
INSERT INTO RecordAttribute
SET id=NULL,
BaseRecordId=1,
AttributeType='Hair';
AttributeValue='Red';
INSERT INTO RecordAttribute
SET id=NULL,
BaseRecordId=1,
AttributeType='Name';
AttributeValue='Alan';
INSERT INTO RecordAttribute
SET id=NULL,
BaseRecordId=1,
AttributeType='Name';
AttributeValue='Davis';
INSERT INTO BaseRecord SET id=2, name='Alan Smith'
Now create the RecordAttribute data:
INSERT INTO RecordAttribute
SET id=NULL,
BaseRecordId=2,
AttributeType='Eyes',
AttributeValue='Blue';
INSERT INTO RecordAttribute
SET id=NULL,
BaseRecordId=2,
AttributeType='Hair';
AttributeValue='Brown';
INSERT INTO RecordAttribute
SET id=NULL,
BaseRecordId=2,
AttributeType='Name';
AttributeValue='Alan';
INSERT INTO RecordAttribute
SET id=NULL,
BaseRecordId=2,
AttributeType='Name';
AttributeValue='Smith';
Now you can find what you want in a very freeform fashion:
SELECT id, name FROM BaseRecord
WHERE id=BaseRecordId
AND (
AttributeValue="Blue"
OR AttributeValue="Green"
OR AttributeValue="Red"
)
GROUP BY BaseRecordId
etc