0

I'm having an issue which i don't know how to get around. When I try compare data in my SQL query, it won't work because there is no 0 before the 1. Example, 01.

So if I try select something from a database where 1 < 50, it won't work. It needs to be 01 < 50.

    $sql = mysqli_query($connect, "SELECT * FROM table WHERE del_thread < del_limit");

Is there anything i can add to del_thread to add the 0 beforehand.

Liambails1
  • 45
  • 5
  • 1
    What are the data types of the del_thread and del_limit columns? Can you provide some sample data in a table structure (not an image)? – griv Sep 01 '22 at 01:00
  • Data type is Varchar (255). – Liambails1 Sep 01 '22 at 01:02
  • For both columns? del_thread and del_limit? – griv Sep 01 '22 at 01:11
  • I've just changed them both to int (255) and it's working now. – Liambails1 Sep 01 '22 at 01:16
  • Great. I figured that might have been the issue. You can do string comparisons using logical operators like less than `<` [See Comparisons with charactersets/collations](https://stackoverflow.com/questions/26080187/sql-string-comparison-greater-than-and-less-than-operators), but since you were using numeric values, you're better off casting it, or even better, adjusting the table to an integer `INT` like you did. – griv Sep 01 '22 at 01:48

0 Answers0