-2

thank you for you answer!!!

enter image description here table is this picture

 SELECT * FROM 
    vehicle_warning_message v 
    WHERE 
    v.capture_time >= "2023-10-03%" 
    AND v.capture_time <= "2023-11-03%";

enter image description here Why can the value of 2023-11-03 be displayed, but not the value of 2023-10-03? The two values are the maximum time of the day, namely "2023-10-03 23:59:59" and "2023-11-03 23:59:59".

  • 1
    `%` symbol works only in `LIKE` – Iłya Bursov Feb 20 '23 at 01:32
  • [Please do not upload images of code/data/errors.](//meta.stackoverflow.com/q/285551) – Ken White Feb 20 '23 at 01:44
  • Wildcards (`%` or `_`) only work in a `LIKE` statement, and only on character (string) data. Outside that `LIKE` statement, it's just a plain character. You should find a good SQL tutorial to learn the basics of using the language. It will save you a lot of wasted time in the future if you learn those basics instead of just flailing around throwing in code you don't understand. – Ken White Feb 20 '23 at 01:46
  • @Ken White I just want to know why this phenomenon occurs and whether it has anything to do with the source code. – a8030962 Feb 20 '23 at 02:07
  • I've already explained that - wildcards are **only valid in a LIKE clause, and only with character data. Outside that LIKE statements, they are simply characters** and are treated like any other character. `2023-11-03` is less than or equal to `2023-11-03%`, but `2023-10-03` is NOT greater than `2023-10-03`, because `2023-10-03` is shorter (because it doesn't have the `%` sign. You'll find you have the same problem if you replace both of the `%`s with `a` or `X` or any other character. It's not a *phenomenon* - it's simply basic SQL. – Ken White Feb 20 '23 at 02:10
  • @Ken White ok ok , thank you for your answer,i understand , Could you recommend some mysql books for me? – a8030962 Feb 20 '23 at 02:20
  • No. Google can find you books and tutorials. Your question here is about plain old SQL, not anything specific to MySQL. Any good tutorial can teach you the basics of SQL. – Ken White Feb 20 '23 at 02:22

1 Answers1

0

If your date-time column is of type string, then the expression '>= "2023-10-03%"' means to search for all values in alphabetical order greater than or equal to '2023-10-03%'. The percent sign is a symbol above which the search will not search in the ASCI table. Therefore, "2023-10-03" is not displayed.