* Hassan Shaikh
> Which one of the following statements is more efficient?
>
> SELECT * FROM COUNTRY WHERE LEFT(CNNAME,1)='B';
>
> Or
>
> SELECT * FROM COUNTRY WHERE CNNAME LIKE 'B%';

The second statement will normally be the most effective, because the server
don't need to perform a function on the column for each row. However, the
LIKE operator is relatively "heavy", the _most_ effective in this case is
probably:

SELECT * FROM COUNTRY WHERE CNNAME>='B' AND CNNAME<'C'

 or

SELECT * FROM COUNTRY WHERE CNNAME BETWEEN 'B' AND 'Bzzz'

--
Roger


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to