uksarkar
5 months ago

Getting error on DB query builder

Posted 5 months ago by uksarkar

This is my code,

$results = DB::table('membership_user')
               ->select(
                  'membership_user.id,
                  memberships.name,
                  memberships.price,
                  memberships.shop_limit,
                  membership_user.status,
                  membership_user.created_at,
                  membership_user.updated_at')
               ->join('users','users.id', '=', 'membership_user.user_id')
               ->join('memberships', 'memberships.id', '=', 'membership_user.membership_id')
               ->limit(10)
               ->get();

How to solve the following error?

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.`price, memberships`.`shop_limit, membershi' at line 1 (SQL: select `membership_user`.`id, memberships`.`name, memberships`.`price, memberships`.`shop_limit, membership_user`.`status, membership_user`.`created_at, membership_user`.`updated_at` from `membership_user` inner join `users` on `users`.`id` = `membership_user`.`user_id` inner join `memberships` on `memberships`.`id` = `membership_user`.`membership_id` limit 10)

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