need help with query.
Here's my table specs
1st query: "SELECT * FROM clients WHERE private='no'";
`id` tinyint(11) NOT NULL auto_increment,
`name` varchar(70) NOT NULL default '',
`email` varchar(100) NOT NULL default '',
`title` varchar(50) NOT NULL default '',
`phone` varchar(20) NOT NULL default '',
`company` tinyint(11) NOT NULL default '0',
`owner` tinyint(11) NOT NULL default '0',
`private` enum('yes','no') NOT NULL default 'no',
PRIMARY KEY (`id`)
2nd query: "SELECT * FROM clients WHERE private='yes' and owner='$owner'";
Is there a way i can join those statement on the condition of 'company'. Because i would like to get all clients from 1st and 2nd query where the company field ='$company';
where company = '$company'
thanx r937, i was a little off.
SELECT * FROM clients WHERE company = '$company' AND private='no' OR (private='yes' AND owner='$owner') ORDER BY name;
make sure you test that thoroughly
my interpretation of your original request involved another set of parentheses for the logic to work out correctly
You might want to put some ( ) in there to guarentee it returns what you expect. I never rely on getting the precidence correct and always force it with brackets.