我需要什么
取消订阅tinyint(6)
1,1,4,5,1,1,......等
sql查询
SELECT e0_.metadata AS metadata0, u1_.unsubscribe AS unsubscribe1, u1_.id AS id2, u1_.linkedin_id AS linkedin_id3, u1_.facebook_id AS facebook_id4, u1_.linkedin_profile AS linkedin_profile5, u1_.profile AS profile6,
CASE WHEN u1_.linkedin_id <> ''
OR u1_.facebook_id <> ''
THEN 1
ELSE 0
END AS sclr7,
CASE WHEN e0_.edition =23932
THEN 'current'
ELSE 'past'
END AS sclr8
FROM event_visitor e0_, user u1_
WHERE e0_.user = u1_.id
AND e0_.event =25162
AND e0_.published =1
AND e0_.showme =1
GROUP BY e0_.user
ORDER BY sclr7 DESC , e0_.id DESC , LENGTH( u1_.unsubscribe )
LIMIT 30
我试过的解决方案。
但没有解决方案在tiny int数据类型中工作。
问题
o / p应该是
all 1 should be at top .
最后经过谷歌搜索
按照CAST命令(est_dily_pple as SIGNED INTEGER)ASC
按顺序排序(u1_.unsubscribe AS SIGNED INTEGER)ASC,sclr7 DESC,e0_.id DESC
解决方案我出现了:
Refrence
http://stackoverflow.com/questions/11282571/specific-order-by-in-mysql-statement
我需要实现abs函数学说
dql代码
$from = 'Entities\EventVisitor visitor,Entities\User user';
$qb = $this->em->createQueryBuilder();
$qb->select("visitor.metadata,ABS( u1_.unsubscribe )as unsubscribe)
->add('from',$from)
->where('visitor.user=user.id')
->groupBy('visitor.user')
->orderBy('unsubscribe','asc')
error 500 internal error.