Reputation: 15
Here is my MySQL table structure
CREATE TABLE `tbl_bookstore` (
`id` int(11) NOT NULL,
`p_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`bookstore_name` varchar(200) NOT NULL,
`phone` text NOT NULL,
`postal_code` varchar(20) NOT NULL,
`address` varchar(250) NOT NULL,
)
Insert Query
INSERT INTO `tbl_bookstore` (`id`, `p_id`, `user_id`, `bookstore_name`, `phone`, `postal_code`, `address`) VALUES
(1, 0, 2, 'Bookstore 1', '1122334455', 'AZX AZX', 'Street Park, Avenue'),
(2, 0, 1, 'Bookstore 1', '1122334455', 'AZX azx', 'Street Park, Avenue'),
(3, 0, 4, 'Bookstore 3', '2233445566', 'AZX AZX', 'park Street,Avnue');
If I search any bookstore_name for ex. Bookstore 1 it should search both "Bookstore 1"
and "Bookstore1"
from the table column bookstore_name
.
With and without space for the same word
Upvotes: 0
Views: 37
Reputation: 37493
Tryt this:
SELECT *
FROM tbl_bookstore
WHERE replace(bookstore_name, ' ', '') like '%Bookstore1%'
Upvotes: 2