Using Substring in MySQL criteria

后端 未结 1 1969
难免孤独
难免孤独 2021-02-18 23:06

I\'m trying to fetch all instances where the 1st letter of a person\'s first name is equal to P.

This is what I came up with, which doesn\'t return anything:

相关标签:
1条回答
  • 2021-02-18 23:31

    The reason your expression doesn't work is that substring() positions are 1-based

    Try either of these:

    where FirstName like 'P%'
    

    or

    where substring(FirstName,1,1) = 'P'
    
    0 讨论(0)
提交回复
热议问题