Yii Framework Forum: Yii Criteria Condition Not Working Sql Error - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii Criteria Condition Not Working Sql Error Rate Topic: -----

#1 User is offline   Chintan Chiku 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 20-March 14

Posted 19 May 2014 - 07:18 AM

$criteria->condition .= 'UserID = '.$userId.' UNION
(
    SELECT * FROM display WHERE 
    UserID IN 
    (
        SELECT DISTINCT UserID FROM lkusergroup WHERE 
        GroupID IN
        (
            SELECT GroupID FROM lkusergroup WHERE UserID = '.$userId.'
        )
    )
)';

i m trying to execute above code but getting following error

    CDbCommand failed to execute the SQL statement: SQLSTATE[21000]: 
Cardinality violation: 1222 The used SELECT statements have a different number of columns. The SQL statement executed was:
SELECT COUNT(*) FROM `display` `t` WHERE UserID = 2 UNION
        (
        SELECT * FROM display WHERE
        UserID IN
        (
        SELECT DISTINCT UserID FROM lkusergroup WHERE
        GroupID IN
        (
        SELECT GroupID FROM lkusergroup WHERE UserID = 2
        )
        )
    ) 

why query generating count(*) this is the actual issue. i tried may way to solve this error bt failed any suggestions ?
0

#2 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,707
  • Joined: 04-March 10
  • Location:UK

Posted 19 May 2014 - 07:24 AM

I suspect that it's being generated to calculate the total number of rows that a grid view's filters return. What specifically are you trying to do?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users