SELECT SQL_CALC_FOUND_ROWS * FROM ( (SELECT 1 AS orderField, mem. fname
, mem. lname
, mem. profilenam
, mem. mem_id
, mem. photo
, mem. ethnicity
, mem. profile_type
, mem. gender
, mem. verified
, mem. deleted
FROM members AS mem INNER JOIN network AS net ON net.frd_id = mem.mem_id WHERE net.mem_id= '1728' AND (mem. profilenam
LIKE '%abc%' OR lname LIKE 'abc%' OR CONCAT(fname, ' ', lname) LIKE 'abc%') ) UNION (选择 2 作为 orderField,
fname
,
lname
,
profilenam
,
mem_id
,
photo
,
ethnicity
,
profile_type
,
gender
,
verified
,
deleted
FROM members
WHERE ( profilenam
LIKE '%abc%' OR lname LIKE 'abc%' OR CONCAT(fname, ' ', lname) LIKE 'abc%') ) ) AS t WHERE t.verified='Y ' 和T。mem_id
不在 (1,2,3,4,5,1728) 和 t 中。deleted
='N' GROUP BY t.mem_id ORDER BY t.orderField,t.profilenam DESC 0,50
问问题
53 次
1 回答
0
DB::statement("SELECT SQL_CALC_FOUND_ROWS * FROM ( (SELECT 1 AS orderField, mem.fname, mem.lname, mem.profilenam, mem.mem_id, mem.photo, mem.ethnicity, mem.profile_type, mem.gender, mem.verified, mem.deleted FROM members AS mem INNER JOIN network AS net ON net.frd_id = mem.mem_id WHERE net.mem_id= '1728' AND (mem.profilenam LIKE '%abc%' OR lname LIKE 'abc%' OR CONCAT(fname, ' ', lname) LIKE 'abc%') ) UNION (SELECT 2 AS orderField, fname, lname, profilenam, mem_id, photo, ethnicity, profile_type, gender, verified, deleted FROM members WHERE (profilenam LIKE '%abc%' OR lname LIKE 'abc%' OR CONCAT(fname, ' ', lname) LIKE 'abc%') ) ) AS t WHERE t.verified='Y' AND t.mem_id NOT IN (1,2,3,4,5,1728) AND t.deleted='N' GROUP BY t.mem_id ORDER BY t.orderField,t.profilenam DESC 0,50");
于 2016-02-08T11:24:53.967 回答