Sunday 15 March 2015

Differences case sensitivity in SELECT COLUMN and COUNT, mysql? -


OK, I'm confused here. In my database I have 5 rows of this data => "string@domail.com" (all lower case), and this is my code, query1 (I'm using php and mysql):

< Pre> $ str = 'STRING@DOMAIN.COM'; $ Sel = mysql_query ("SELECT COUNT (*) from the table where` column` = '{$ str}' '); $ Num = mysql_num_rows ($ sel); ebb $ num;

The result is 1. But if I change to Query 2

  select column from the table where `column` = '{$ str}'"  

It returns 5 returns.

And another question is if I want to find the rows in the number of rows of the database, 1 or 2 queries, then which query should I use for the query speed period?

  $ num = mysql_num_rows ($ sel);  

This returns the number of rows you have selected from your query. For a query, when you select COUNT (*) from your table, then it returns a row with one cell: the value of this cell is 5. The second question, select all entries with value from $ str , so mysql_num_rows ($ sel); Really return 5.

For the other question, the first question is more efficient, but if you are looking for the number of rows with the value $ str , then mysql_num_rows () but.


No comments:

Post a Comment