brown2005 Posted August 25, 2006 Share Posted August 25, 2006 Hi,I have three tables[b]members[/b]members_id[b]websites[/b]websites_id[b]websites_hits[/b]websites_hits_idrite in the website_hits table the websites_hits_id is 'members_id websites_id'so wat i want to do is select all the websites from table websites that have no hits (websites_hits) for the member............. Quote Link to comment Share on other sites More sharing options...
trq Posted August 25, 2006 Share Posted August 25, 2006 Your going to need to be alot more desciptive. Quote Link to comment Share on other sites More sharing options...
brown2005 Posted August 25, 2006 Author Share Posted August 25, 2006 say i have member_id is 1i want to select all websites from table websites, for member 1, which have no hits in websites_hits Quote Link to comment Share on other sites More sharing options...
Iyad Posted August 25, 2006 Share Posted August 25, 2006 Number [b]Member websites Hits[/b]1 Brown brown.org 02 Jack jack.net 2like that? Quote Link to comment Share on other sites More sharing options...
brown2005 Posted August 25, 2006 Author Share Posted August 25, 2006 Like this;Hi, member 1,You have not viewed the following websites:-www.test.co.ukwww.notatest.co.ukso basically i want to select all the tables from websites that have no hits for member 1 in websites_hits. Quote Link to comment Share on other sites More sharing options...
Iyad Posted August 25, 2006 Share Posted August 25, 2006 hmm..as far as I know you can connect id 'member' to 'websites'. And then try to make 'if' statement on website hit for every member id. Quote Link to comment Share on other sites More sharing options...
trq Posted August 25, 2006 Share Posted August 25, 2006 Were going to need to see your table structures. Quote Link to comment Share on other sites More sharing options...
brown2005 Posted August 25, 2006 Author Share Posted August 25, 2006 CREATE TABLE `members` ( `members_id` bigint(15) NOT NULL auto_increment, PRIMARY KEY (`members_id`)) TYPE=MyISAM AUTO_INCREMENT=2 ;INSERT INTO `members` VALUES (1);CREATE TABLE `websites` ( `websites_id` bigint(15) NOT NULL auto_increment, `websites_website` varchar(255) NOT NULL default '', `websites_hits` bigint(15) NOT NULL default '0', `websites_hits_unique` bigint(15) NOT NULL default '0', `websites_date` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`websites_id`)) TYPE=MyISAM AUTO_INCREMENT=4 ;INSERT INTO `websites` VALUES (1, 'www.fanaticfootball.co.uk', 0, 3, '2006-08-25 09:53:53');INSERT INTO `websites` VALUES (2, 'www.google.co.uk', 0, 3, '2006-08-25 09:54:03');INSERT INTO `websites` VALUES (3, 'www.bbc.co.uk/sport', 0, 2, '2006-08-25 09:54:10');CREATE TABLE `websites_hits` ( `websites_hits_id` varchar(15) NOT NULL default '0', `websites_hits_user` bigint(15) NOT NULL default '0', `websites_hits_website` bigint(15) NOT NULL default '0') TYPE=MyISAM;INSERT INTO `websites_hits` VALUES ('1 1', 1, 1); Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted August 25, 2006 Share Posted August 25, 2006 Your website_hits_id column is a bad idea, having two pieces of data in one field... Why not just add an additional column, to make the relationships between the tables better?That's just my opinion anyway.As it is, you'll have to manipulate the data in that column, whether it be in the select statement, or in PHP once you have your recordset.RegardsRich Quote Link to comment Share on other sites More sharing options...
brown2005 Posted August 25, 2006 Author Share Posted August 25, 2006 wat ya mean... can u show me? Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted August 25, 2006 Share Posted August 25, 2006 I can't show you as I'm not certain what you're trying to achieve, but I do know that putting two pieces of data in the same column, just concatenated, is a bad idea.Rich Quote Link to comment Share on other sites More sharing options...
scottybwoy Posted August 25, 2006 Share Posted August 25, 2006 HuggieBear is right change your websites hit's table to this :CREATE TABLE `websites_hits` ( `members_id` varchar(15) NOT NULL default '0', `websites_id` bigint(15) NOT NULL default '0', `websites_hits` bigint(15) NOT NULL default '0') TYPE=MyISAM;INSERT INTO `websites_hits` VALUES (1, 1, 0);Then create relationships between member_id and websites_is to your websites_hits table then use :"SELECT websites_id FROM websites_hits WHERE members_id = '$member' AND website_hits = 0" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.