User-908043281 posted
Search in table on two columns
Hello, I need search in doTable on columns "month" and "title" the follow values:
For column "month": Jan, Feb, Mar and Apr;
For column "title": Latium, Abruzzo, Molise, Tuscany, Umbria, Campania and Sardinia.
I tried this query but in the output I don't have one row where it is present in column
title the string "Tuscany and Umbria".
Can you help me?
Thank you in advance.
SELECT *
FROM
`doTable`
WHERE
month LIKE '%Jan%'
OR '%Feb%'
OR '%Mar%'
OR '%Apr%'
AND title LIKE '%Latium%'
OR '%Abruzzo%'
OR '%Molise%'
OR '%Tuscany%'
OR '%Umbria%'
OR '%Campania%'
OR '%Sardinia%';
The doTable, I need extract rows with ID number 1, 2 ad 5 :
DROP TABLE IF EXISTS `doTable`;
CREATE TABLE `doTable` (
`title` longtext,
`month` char(3) DEFAULT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
-- ----------------------------
-- Records of doTable
-- ----------------------------
INSERT INTO `doTable` VALUES ('Umbria and Tuscany are two of Italy\'s most beautiful regions.', 'Jan', '1');
INSERT INTO `doTable` VALUES ('Abruzzo, Latium and Molise National Park is famous in Italy,', 'Jan', '2');
INSERT INTO `doTable` VALUES ('Hi, fairly new to you site so guessing this is a fairly basic question', 'Feb', '3');
INSERT INTO `doTable` VALUES ('I have a question regarding the following question', 'Mar', '4');
INSERT INTO `doTable` VALUES ('Sardinia is the second largest island in the Mediterranean Sea (after Sicily and before Cyprus) and an autonomous region of Italy', 'Mar', '5');
INSERT INTO `doTable` VALUES ('I am a novice and I have uninstalled and reinstalled the community', 'Apr', '6');