Jump to content

Search from Multiple Table Query


Sajesh Mohan

Recommended Posts

hi All

 

I have totaly 6 tables . i need to search from these 6 table using keyword search (LIKE Query)

in 6 table common field is eco_id.

fields are eco_id,heading,img,content,tags......(same field are in the all tables)

 

how we will do the search query.

please help me

 

thanks in advance.

 

 

 

Link to comment
Share on other sites

 

i need to search from multiple tables using like %keyword% .

these are the tables

 

CREATE TABLE IF NOT EXISTS `knews_economy` (
  `eco_id` int(4) NOT NULL AUTO_INCREMENT,
  `heading` varchar(600) NOT NULL,
  `img` varchar(255) NOT NULL,
  `contents` blob NOT NULL,
  `summary` varchar(600) NOT NULL,
  `tags` varchar(600) NOT NULL,
  `pubdate` varchar(255) NOT NULL,
  `inews` enum('YES','NO') NOT NULL DEFAULT 'NO',
  `status` int(2) NOT NULL COMMENT '1 for active 0 for inactive',
  PRIMARY KEY (`eco_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=45 ;

-- --------------------------------------------------------

--
-- Table structure for table `knews_intl`
--

CREATE TABLE IF NOT EXISTS `knews_intl` (
  `eco_id` int(4) NOT NULL AUTO_INCREMENT,
  `heading` varchar(255) NOT NULL,
  `img` varchar(255) NOT NULL,
  `contents` blob NOT NULL,
  `summary` varchar(600) NOT NULL,
  `tags` varchar(600) NOT NULL,
  `pubdate` varchar(255) NOT NULL,
  `inews` enum('YES','NO') NOT NULL DEFAULT 'NO',
  `status` int(2) NOT NULL COMMENT '1 for active 0 for inactive',
  PRIMARY KEY (`eco_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=20 ;

-- --------------------------------------------------------

--
-- Table structure for table `knews_local`
--

CREATE TABLE IF NOT EXISTS `knews_local` (
  `eco_id` int(4) NOT NULL AUTO_INCREMENT,
  `heading` varchar(600) NOT NULL,
  `img` varchar(255) NOT NULL,
  `contents` blob NOT NULL,
  `summary` varchar(600) NOT NULL,
  `tags` varchar(600) NOT NULL,
  `pubdate` varchar(255) NOT NULL,
  `inews` enum('YES','NO') NOT NULL DEFAULT 'NO',
  `status` int(2) NOT NULL COMMENT '1 for active 0 for inactive',
  PRIMARY KEY (`eco_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=24 ;

-- --------------------------------------------------------

--
-- Table structure for table `knews_mnews`
--

CREATE TABLE IF NOT EXISTS `knews_mnews` (
  `eco_id` int(4) NOT NULL AUTO_INCREMENT,
  `heading` varchar(255) NOT NULL,
  `img` varchar(255) NOT NULL,
  `contents` blob NOT NULL,
  `tags` varchar(600) DEFAULT NULL,
  `summary` varchar(600) DEFAULT NULL,
  `pubdate` varchar(255) NOT NULL,
  `status` int(2) NOT NULL COMMENT '1 for active 0 for inactive',
  PRIMARY KEY (`eco_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=41 ;

-- --------------------------------------------------------

--
-- Table structure for table `knews_parliment`
--

CREATE TABLE IF NOT EXISTS `knews_parliment` (
  `eco_id` int(4) NOT NULL AUTO_INCREMENT,
  `heading` varchar(600) NOT NULL,
  `img` varchar(255) NOT NULL,
  `contents` blob NOT NULL,
  `tags` varchar(600) NOT NULL,
  `summary` varchar(600) NOT NULL,
  `pubdate` varchar(255) NOT NULL,
  `inews` enum('YES','NO') NOT NULL DEFAULT 'NO',
  `status` int(2) NOT NULL COMMENT '1 for active 0 for inactive',
  PRIMARY KEY (`eco_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ;

-- --------------------------------------------------------

--
-- Table structure for table `knews_sports`
--

CREATE TABLE IF NOT EXISTS `knews_sports` (
  `eco_id` int(4) NOT NULL AUTO_INCREMENT,
  `heading` varchar(255) NOT NULL,
  `img` varchar(255) NOT NULL,
  `contents` blob NOT NULL,
  `tags` varchar(600) NOT NULL,
  `summary` varchar(600) NOT NULL,
  `pubdate` varchar(255) NOT NULL,
  `inews` enum('YES','NO') NOT NULL DEFAULT 'NO',
  `status` int(2) NOT NULL COMMENT '1 for active 0 for inactive',
  PRIMARY KEY (`eco_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=20 ;

how it is doing ? please help me

 

thanks in advance

 

Link to comment
Share on other sites

Why is this separated out into separate tables?  It looks to me that they could all be stored in one table and add in an extra column which is the news type (i.e. sports, international, local).  Then you would just be doing a query on one table ...

 

Otherwise you would likely want to UNION each of the selects together.

 

~juddster

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.