I would like to know how I can get a single result from a table that is like a phrase.
My table has all the postcodes like so...
B1
B2
B3
CV2
WC1A
and if someone enters say B1 2AB or WC1A 1AB that I wish to find the single result that is like the one entered and obtain the other details in the results.
What query could I use to do this.
My table looks like this...
CREATE TABLE IF NOT EXISTS `postcodes` (
`Pcode` text NOT NULL,
`Grid_N` int(11) NOT NULL DEFAULT '0' COMMENT 'used',
`Grid_E` int(11) NOT NULL DEFAULT '0' COMMENT 'used',
`Latitude` decimal(12,5) NOT NULL DEFAULT '0.00000',
`Longitude` decimal(12,5) NOT NULL DEFAULT '0.00000',
`town` varchar(255) DEFAULT NULL COMMENT 'THIS FIELD WAS ADDED TO USING THE REGION INFO AS SOME TOWNS WERE BLANK',
`region` varchar(255) DEFAULT NULL COMMENT 'this is now not used',
`country` varchar(3) NOT NULL COMMENT 'this is now not used',
`country_string` varchar(16) NOT NULL COMMENT 'used',
`state` text NOT NULL,
`mydummy` text NOT NULL,
KEY `x` (`Grid_N`,`Grid_E`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='DanGibbs.co.uk Free UK Postcode Database';
INSERT INTO `postcodes` (`Pcode`, `Grid_N`, `Grid_E`, `Latitude`, `Longitude`, `town`, `region`, `country`, `country_string`, `state`, `mydummy`) VALUES
('AB10', 392900, 804900, '57.13514', '-2.11731', 'Aberdeen', 'Aberdeen City', 'SCT', 'Scotland', '', 'UNITED KINGDOM'),
('AB11', 394500, 805300, '57.13875', '-2.09089', 'Aberdeen', 'Aberdeen City', 'SCT', 'Scotland', '', 'UNITED KINGDOM'),
('AB12', 393300, 801100, '57.10100', '-2.11060', 'Aberdeen', 'Aberdeen City', 'SCT', 'Scotland', '', 'UNITED KINGDOM'),
('AB13', 385600, 801900, '57.10801', '-2.23776', 'Milltimber', 'Aberdeen City', 'SCT', 'Scotland', '', 'UNITED KINGDOM'),
('AB14', 383600, 801100, '57.10076', '-2.27073', 'Peterculter', 'Aberdeen City', 'SCT', 'Scotland', '', 'UNITED KINGDOM'),
('AB15', 390000, 805300, '57.13868', '-2.16525', 'Aberdeen', 'Aberdeen City', 'SCT', 'Scotland', '', 'UNITED KINGDOM'),
('AB16', 390600, 807800, '57.16115', '-2.15543', 'Aberdeen', 'Aberdeen City', 'SCT', 'Scotland', '', 'UNITED KINGDOM'),
('AB21', 387900, 813200, '57.20960', '-2.20033', 'Aberdeen Airport', 'Aberdeen City', 'SCT', 'Scotland', '', 'UNITED KINGDOM'),
('AB22', 392800, 810700, '57.18724', '-2.11913', 'Bridge Of Don', 'Aberdeen City', 'SCT', 'Scotland', '', 'UNITED KINGDOM'),
('AB23', 394700, 813500, '57.21242', '-2.08776', 'Aberdeen', 'Aberdeen City', 'SCT', 'Scotland', '', 'UNITED KINGDOM');