0

In order to understand my question let me begin with let me point how my user_records table looks like (Below)

=====================================
ID  FirstName LastName   Mtr
-------------------------------------
2   Tom       Bradley    972379-nai
3   Floyd     John       438909-jersey
4   Craig     Tommy      984389-new
5   Nelson    Harvey     783902-tow
6   Dean      Wayne      984389-jdd
7   Craig     Tommy      984389-ird
8   Mark      John       438909-carli
=======================================

You will realise that under Mtr column we have values that have an integer part as well as an alphabetical part.

The challenge is to return results from a query which the WHERE clause is column Mtr but only the integer part.

This is what I mean:

$reference = 984389;//This will be passed to the WHERE clause
/*
what is expected is that the query returns records whose Mtr part contains $reference
*/
$query = "SELECT * FROM user_records WHERE Mtr='$reference'; 
$result = mysqli_query($conn,$query);

The expected result is that the query returns records 4, 6 and 7

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

-1

$query = "SELECT * FROM user_records WHERE Mtr LIKE '%$reference%';

$result = mysqli_query($conn,$query);

Mangesh Sathe
  • 1,987
  • 4
  • 21
  • 40