Need help on using LIKE

Hi,

Good day!

I encountered difficulties in checking of the data is like on the data from my table.

I have table

wms_picking

and I have lot_number field and value = ‘LO130318001-LO130318002’ and item_code = ‘MAT-CHE-0010’
then I have variable:

$lot_number = ‘LO130318001LO130318002’;
$mat_code = ‘MAT-CHE-0010’;

I created query:

select s.sr_id, p.item_code, p.lot_number from sr_chemicals AS s JOIN wms_picking AS p ON (s.sr_id = p.sr_id)
WHERE p.item_code = ‘$mat_code’ and p.lot_number LIKE ‘%$lot_number%’;

select s.sr_id, p.item_code, p.lot_number from sr_chemicals AS s JOIN wms_picking AS p ON (s.sr_id = p.sr_id)
WHERE p.item_code = ‘MAT-CHE-0010’ and p.lot_number LIKE ‘%LO130318001LO130318002%’;

and I got no result, but I just want to get the result of lot_number field field and value = ‘LO130318001-LO130318002’ and item_code = ‘MAT-CHE-0010’.

Any help is highly appreciated.

Thank you so much.

AND REPLACE(p.lot_number,'-','') = '%$lot_number%';

It works…

Thank you so much

are you sure?

i left those percent signs in there to see if you were awake

select s.sr_id, p.item_code, p.lot_number from sr_chemicals AS s JOIN wms_picking AS p ON (s.sr_id = p.sr_id)
WHERE p.item_code = ‘$mat_code’ and REPLACE(p.lot_number,‘-’,‘’) LIKE ‘%$lot_number%’

AND REPLACE(p.lot_number,'-','') [B][COLOR="#FF0000"]=[/COLOR][/B] '$lot_number';

:slight_smile:

Thank you so much