Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

satheeshkumarj's avatar

WhereIn condition with UUID not working

public function skills($id)
    { 
        $skills = DB::table("industry_skill_sets")
                    ->whereIn('industry_id', [$id])
                    ->pluck("name","id");
                    print_r($skills); exit;
    }

Here id is UUID seperated by comma. When I echo Id I am getting

2b5e5507-7e01-45fe-b0ed-331135479061,7c816e0f-d6e2-489c-bdce-df064b3e99f9

When I use this variable in WhereIn condition , It shows error

SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type uuid: "2b5e5507-7e01-45fe-b0ed-331135479061,7c816e0f-d6e2-489c-bdce-df064b3e99f9"
0 likes
2 replies
Snapey's avatar
Snapey
Best Answer
Level 122

$id is your uuids string?

You need to convert it to an array if you want to use it in whereIn

        $skills = DB::table("industry_skill_sets")
                    ->whereIn('industry_id', explode(',',$id))
                    ->pluck("name","id");
1 like

Please or to participate in this conversation.