MySQL: check whether two fields on a model are always the same?
Posted
by AP257
on Stack Overflow
See other posts from Stack Overflow
or by AP257
Published on 2010-05-21T21:22:54Z
Indexed on
2010/05/21
21:30 UTC
Read the original article
Hit count: 221
mysql
Sorry if this is a duplicate question, I'm a total database newbie and I'm probably using the wrong terminology to search for answers.
I have a MySQL table as follows:
+------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+-------+
| placeid | int(11) | NO | PRI | NULL | |
| grid | varchar(120) | YES | | NULL | |
| vill | varchar(300) | YES | | NULL | |
+------------+---------------+------+-----+---------+-------+
I'd like to find out whether 'grid' and 'vill' always occur in the same combinations or not.
Maybe it'd be clearer with an example:
placeid, grid, vill
1, TM1, Suffolk
2, TM1, Suffolk
3, WA8, Newcastle
4, WA8, Newcastle
5, WA8, York
I'd like to construct a query that returns 'WA8' but not 'TM1', because 'WA8' occurs in combination with more than one vill.
I would be SO grateful for any help!
© Stack Overflow or respective owner