0

I have a table called "Inventory" that I need to find the max value of column labeled "ID". The data in the column looks like this: ID column data

The ID is made up of text, relevant to the item, followed by a hex value (TB-00001). What I am trying to do is return the max value of the column, but I only need the max value of a certain ID. For example, if the user enters in "TB" in a text field, return the max value of only the ID's that have "TB" in their ID. If a user enters in "WCM", return the max value of only the ID's that have "WCM" in their ID. And so on...

I have the following code, but it is only returning the max value of the entire column:

SELECT MAX(Inventory.ID) AS "ID" FROM Inventory

Thank you in advance.

Shadow
  • 32,277
  • 10
  • 49
  • 61
csilk47
  • 1
  • 1
  • You are looking for the [`LIKE`](https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html#operator_like) operator: `SELECT MAX(ID) as ID FROM Inventory WHERE ID LIKE 'TB%';` – JNevill May 09 '22 at 14:51

0 Answers0