0

Welcome

I am using Laravel 6.6.2 and I want to execute my query. That work if I execute my query in MySql-workbench (with sql fromat). I have this following problem, 2 equals values are not equal.

$myId = DB::table("masterTable")
    ->select("ass_group_user.group_pgr_id","group.pgr_id")
    ->leftJoin("user","user.status_flag","=","gen_client.status_flag")
    ->leftJoin("group","group.pgr_foreign_key","=","gen_client.id")
    ->leftJoin("ass_group_user","ass_group_user.user_id","=","user._id")
    ->Where("user.name","=","myName")
    ->Where("ass_group_user.group_pgr_id","=","group.pgr_id")
->get();

Return empty array.
If I actually write that instead of "Where("ass_group_user.group_pgr_id","=","group.pgr_id")"

->Where("ass_group_user.group_pgr_id","=",6)
->Where("group.pgr_id","=",6)

return what I want.
Both of them are Int.

Thank you

1 Answers1

0

This is too long for a comment.

If both the columns are ints, I don't see how this could happen. However, if they were strings, you could have situations such as this:

'06' = 6
'006' = 6

but:

'06' <> '006'

That is because in a mixed comparison with a number and a string, the string is converted to a number.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786