Jump to content

Need help on using LIKE


Recommended Posts

Hi, Good day!I encountered difficulties in checking of the data is like on the data from my table.I have tablewms_pickingand 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.

Link to post
Share on other sites

That's not what LIKE does. This 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-CHE-0010' and p.lot_number LIKE '%LO130318001LO130318002%'; Is asking the database to return records where the lot_number field contains the text "LO130318001LO130318002".

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...