Shkurta Abazi Shkurta Abazi - 10 months ago 77
MySQL Question

PHP MYSQLI Count Row Correct


enter image description here

Hello i try to finds all hashtags with name #c3 and mysqli query show me: 3 rows but correct is 2 rows with #c3 ??? where is problem ? I want to show me 2Rows !

$sql_query = mysqli_query($Connection, "SELECT * FROM my_table WHERE hashtag LIKE '%#c3%'");
echo mysqli_num_rows($sql_query);


To answer this and as left in comments (by myself)

Use '%#c3' by removing the last %

Using LIKE, the % wildcard does the following and a few examples:

%XXX% - Matches anything before and after XXX

%XXX - Matches anything before XXX

XXX% - Matches anything after XXX.


Plus, should there be any user input, consider using a prepared statement:

It will help against a potential SQL injection.