newphpcoder Posted March 18, 2013 Share Posted March 18, 2013 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 comment Share on other sites More sharing options...
justsomeguy Posted March 18, 2013 Share Posted March 18, 2013 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 comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now