Jump to content

small php/mysql help needed


TFG

Recommended Posts

i need help on this, can someone please look at this,

 

let's say there are two tables on my database

1. category table having column id with values like 1 to 10

2. details table having column category with the values like 2, 4, 6, 8, 10

 

so i want to list 5 values from category table's id columns but only those values that are in details table category column,

 

how do i do it pls guide me.

 

 

Link to comment
https://forums.phpfreaks.com/topic/101318-small-phpmysql-help-needed/
Share on other sites

actually i mean like this there will be first table like this

CREATE TABLE `category` (
  `id` mediumint(9) NOT NULL auto_increment,
  `title` text collate latin1_general_ci NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=945 ;

 

 

which will have like this

 

INSERT INTO `category` (`id`, `title`) VALUES
(1, 'Adriana'),
(2, 'Alicia'),
(3, 'Anna'),
(4, 'Avril'),
(5, 'Britney'),
(6, 'Cameron'),
(7, 'Carmen'),
(8, 'Charlie'),
(9, 'Charlize'),
(10, 'Christina');

 

and there will be another table like this

 

 

CREATE TABLE `details` (
  `id` int(6) NOT NULL auto_increment,
  `category` text collate latin1_general_ci NOT NULL,
  `brief` text collate latin1_general_ci NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=6470 ;

 

 

and will have like this

 

(1, '2', 'brief of category with id 2'),
(2, '4', 'brief of category with id 4'),
(3, '6', 'brief of category with id 6'),
(4, '8', 'brief of category with id 8'),
(5, '10', 'brief of category with id 10');

 

and now wt i want is to list 5 categories from the category table only if those id are in details talble

 

like category with id 2 is in details table now i want to list that not directly from the details table but from the category table if the same value exist in details table

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.