and try it yourself first. See what works and what not. Then search in the forum for the issues you are seeing and if you cannot find the solution ask specific questions in the forum rather than asking for someone to give you the final solution.
select company.company_name AS company, company.website AS domain_name, company.customer_id AS id,
contact.email AS emailid FROM customer_company AS company LEFT JOIN (SELECT email,
customer_id FROM contact GROUP BY customer_id ) AS contact ON
( company.customer_id = contact.customer_id ) WHERE company.group_id = 7
and ORDER BY customer_id DESC;
[/sql]
I am using the criteria given below. When I executed… the values returned is having 1…
Can anybody help to find any mistake in the criteria I am using?
$criteria = new CDbCriteria;
$criteria->select = 't.company_name AS company, t.website AS domain_name, t.customer_id AS id,'.
'contact.email AS emailid';
$criteria->join = 'LEFT JOIN (SELECT email, customer_id FROM contact GROUP BY customer_id ) AS contact ON ( t.customer_id = contact.customer_id )';
$criteria->compare('t.group_id', 7);
$criteria->order = 't.customer_id DESC';
$model = Customer::model()->find($criteria);
What do you get when you execute the whole query in phpmyadmin and what do you get when you print it in yii. Also can you please show how exactly you are printing the result in Yii.
ok simplify your query above. Remove the join just make it very simple until it works. Once you get it to work start building it back up again until you hit into what’s the problem