Simple Sql Search Modification

Simple Sql Search Modification

I need a revised search string for the following:

There are two tables TRACKER and HISTORY. The TRACKER table contains unique liens for items and the HISTORY table has lines that record the location history for each item in the TRACKER table. I will provide both tables after selecting a programmer.

I need a search to tell me which barcodes are in a certain location at any given time. Below is the search that someone else made for me.

$trackerdb is the TRACKER table
$historydb is the HISTORY table

$result = mysql_query(”
SELECT DISTINCT h.barcode, h.location, $trackerdb.*
FROM $historydb AS h
LEFT JOIN $historydb AS h2 ON h.time < h2.time AND h.barcode = h2.barcode
INNER JOIN $trackerdb ON h.barcode = $trackerdb.file_barcode
WHERE h2.time IS NULL AND h.location LIKE ‘” . mysql_real_escape_string($_GET[‘find_location’]) . “%’
ORDER BY h.time DESC;
“);
if (!$result) { include(“./dberror.html”); }
$num_rows = mysql_num_rows($result);
echo(“<DIV class=’maintext’>Found ” . $num_rows . ” file(s) in location ” . $_GET[‘find_location’] . “<BR>”);
if ($num_rows == 0) {
echo(“Unable to find any files”);
exit(); }

The problem is it is not displaying accurate results. I think this is because is uses a LIKE parameter and the historical location information has places like “Chirs A.” “Chirs D.” “Christoper”

When I need to see what is in the location Chris D. it will return items with Christopher.

I need the search argument changed so that it will correctly output only the barcodes from the TRACKER that are presently in the searched location.

Payment escrow is ok. Payment only released when code is tested working ok.

Leave a Reply

Your email address will not be published. Required fields are marked *