Kelvin De Moya
Kelvin De Moya

Reputation: 5704

MySQL+VB.NET - Search in a column with a criteria, then select the highest value in the result

I'm using VB.NET with the MySQLConnector, I have an ID column with differents values, i.e:

101
102
201
202
203
302
304
305
306

I want to select all the values that start with "3" and then, select the MAX of them, in this case, "306"

Any suggestion? Thanks

Upvotes: 1

Views: 691

Answers (1)

mellamokb
mellamokb

Reputation: 56789

select max(id) from Data
where left(cast(`id` as char(10)), 1) = '3';

Demo: http://sqlize.com/w2tJP1T7ur

Upvotes: 1

Related Questions