1 year ago

Laravel query Builder

Posted 1 year ago by deepu07

Hey folks, I'm stuck-up with query builder. I have one raw sql query it is working when you execute in sequel Pro. but not working in code. can anyone help me on this? Thanks in advance.

FROM table1 a
JOIN (SELECT name, age, COUNT(*)
FROM table2 
GROUP BY name, age
HAVING count(*) > 1 ) b
ON =
AND a.age = b.age

//Query Builder

        $data = \DB::table("table1 AS a")
              name, age, COUNT(*),
              FROM table2
              GROUP BY, b.age
              HAVING count(*) > 1
              ) as b"), function($join){
                $join->on("", "=", "")->on("a.age", "=", "b.age");


  SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the rig  
  ht syntax to use near 'FROM table2                                                                                                                
              GROUP BY, b.age'                                                                                                                                                                                                                                                                                          


Please sign in or create an account to participate in this conversation.