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

lifesound's avatar

Easy query that should not give null

$product = Product::where('serial', $serial)->orWhere('mfg_serial', $serial)->first();

why this query yields null where I have the serial and I am sure of that

0 likes
8 replies
SilenceBringer's avatar

@lifesound if you have it - it should works. It means either you have incorrect value in $serial OR you DO NOT have record with this serial

Use any db client to check the database directly with the query

select * from products where `serial` = "put_serial_here" or `mfg_serial` = "put_serial_here"
MohamedTammam's avatar

Please copy the record from the database and post it here. Also please post the result of dd($serial)

lifesound's avatar

weird it was my SQL problem and after restart it worked

Lumethys's avatar

@lifesound sound like some caching issue, you might want to disable it or something might work unexpectedly

lifesound's avatar
lifesound
OP
Best Answer
Level 17

after a hard night it was a space problem there were a little space that’s not trimmed

Please or to participate in this conversation.