Jump to content

Recommended Posts

Hey guys,

I am trying to make a MySQL query but i am not sure how to build it up ... I need to count the numbers of members that are not added to the users contact list for a giving member id from the user table provided below. The "user_id" col in the contact table is the member to who the contact belongs to not the user id of the contact ... that's what complicates everything ...

 

CREATE TABLE IF NOT EXISTS `contact` (
  `id` int(9) NOT NULL auto_increment,
  `user_id` int(9) NOT NULL,
  `name` varchar(50) NOT NULL,
  `username` varchar(50) NOT NULL,
  `address` varchar(250) NOT NULL,
  `cp` varchar(50) NOT NULL,
  `tel_h` varchar(100) NOT NULL,
  `tel_w` varchar(100) NOT NULL,
  `tel_c` varchar(100) NOT NULL,
  `note` blob NOT NULL,
  `added_date` varchar(100) NOT NULL,
  `blessingstairs_ref` int(9) NOT NULL,
  `email` varchar(250) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

CREATE TABLE IF NOT EXISTS `jos_users` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(255) NOT NULL default '',
  `username` varchar(150) NOT NULL default '',
  `email` varchar(100) NOT NULL default '',
  `password` varchar(100) NOT NULL default '',
  `usertype` varchar(25) NOT NULL default '',
  `block` tinyint(4) NOT NULL default '0',
  `sendEmail` tinyint(4) default '0',
  `gid` tinyint(3) unsigned NOT NULL default '1',
  `registerDate` datetime NOT NULL default '0000-00-00 00:00:00',
  `lastvisitDate` datetime NOT NULL default '0000-00-00 00:00:00',
  `activation` varchar(100) NOT NULL default '',
  `params` text NOT NULL,
  `referenced_by` int(99) NOT NULL,
  `referenced_to` int(99) NOT NULL,
  `cron_start` varchar(40) NOT NULL,
  `cron_end` varchar(40) NOT NULL,
  `cron` varchar(40) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `usertype` (`usertype`),
  KEY `idx_name` (`name`),
  KEY `gid_block` (`gid`,`block`),
  KEY `username` (`username`),
  KEY `email` (`email`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=509 ;

Link to comment
https://forums.phpfreaks.com/topic/154370-querry-problem/
Share on other sites

I need to count the numbers of members that are not added to the users contact list for a giving member id from the user table provided below. The "user_id" col in the contact table is the member to how the contact belongs to not the user id of the contact ... that's what complicates everything ...

 

You need to count what >>--(???)-->

Link to comment
https://forums.phpfreaks.com/topic/154370-querry-problem/#findComment-811588
Share on other sites

lol yeah ... umm let me try again

 

User 23 has 2 contacts

 

111@222.com

333@444.org

 

In the referal page he has 5 referals. I need to count the number of referals that are not in the contact list.

 

In this case the awnser would be 2 Then in an other page i need to fetch them then loop them

Link to comment
https://forums.phpfreaks.com/topic/154370-querry-problem/#findComment-811595
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.