Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Using WildCards in Conjunction with the IN keyword?

$
0
0
This is the Serial number I am Searching my Database for: "ALCLL5096747"

My Query:

SELECT
tbl_shop.shop_desc,
tbl_location.location_desc,
tbl_inventory.location_id,
tbl_inventory.shop_id,
tbl_inventory.uid,
tbl_inventory.part_number,
tbl_inventory.model_number,
tbl_inventory.serial_number,
tbl_inventory.desc,
tbl_inventory.date_modified
FROM tbl_inventory
INNER JOIN tbl_shop ON tbl_inventory.shop_id = tbl_shop.shop_id
INNER JOIN tbl_location ON tbl_inventory.location_id = tbl_location.location_id WHERE '5096747' IN (tbl_inventory.model_number, tbl_inventory.part_number, tbl_inventory.serial_number)
ORDER BY CASE tbl_inventory.location_id WHEN 1 THEN 2 ELSE 1 END , tbl_inventory.location_id

I'm having troubles pulling the serial number as Written in the query above (WHERE '5096747').

I'm pulling the information off a BarCode which supplies the last portion (Just the numbers) of the serial number.

When I search 5096747 this query returns nothing however, if I were to search 'L5096747' my part is reflected in our database. is anyone able to explain to me why this is?

I have tried using wildcards in front and behind the serial number to no avail.
"%5096747", "%5096747%", "5096747%" :confused:

I need my query to return anything that contains '5096747' in those three columns.

I tried 'LIKE'.. but in conjunction with 'IN' i can't make any headway.

Viewing all articles
Browse latest Browse all 13329

Trending Articles