Jump to content
php.lv forumi

Ierakstu skaitīšana lielā datubāzē


nekonezinu

Recommended Posts

  • Replies 60
  • Created
  • Last Reply

Top Posters In This Topic

Dažkārt māk:

The index also can be used for LIKE comparisons if the argument to LIKE is a constant string that does not start with a wildcard character. For example, the following SELECT statements use indexes:

 

SELECT * FROM tbl_name WHERE key_col LIKE 'Patrick%';
SELECT * FROM tbl_name WHERE key_col LIKE 'Pat%_ck%';

 

In the first statement, only rows with 'Patrick' <= key_col < 'Patricl' are considered. In the second statement, only rows with 'Pat' <= key_col < 'Pau' are considered.

 

The following SELECT statements do not use indexes:

 

SELECT * FROM tbl_name WHERE key_col LIKE '%Patrick%';
SELECT * FROM tbl_name WHERE key_col LIKE other_col;

 

In the first statement, the LIKE value begins with a wildcard character. In the second statement, the LIKE value is not a constant.

 

If you use ... LIKE '%string%' and string is longer than three characters, MySQL uses the Turbo Boyer-Moore algorithm to initialize the pattern for the string and then uses this pattern to perform the search more quickly.

Link to comment
Share on other sites

Latvia:

Array ( [id] => 1 [select_type] => SIMPLE [table] => vardi [type] => range [possible_keys] => vards_in [key] => vards_in [key_len] => 765 [ref] => [rows] => 1 [Extra] => Using where )

 

music:

Array ( [id] => 1 [select_type] => SIMPLE [table] => vardi [type] => range [possible_keys] => vards_in [key] => vards_in [key_len] => 765 [ref] => [rows] => 5 [Extra] => Using where )

 

dvdrip:

Array ( [id] => 1 [select_type] => SIMPLE [table] => vardi [type] => range [possible_keys] => vards_in [key] => vards_in [key_len] => 765 [ref] => [rows] => 2 [Extra] => Using where )

Link to comment
Share on other sites

$aax = mysql_query("SELECT * FROM vardi WHERE MATCH (vards) AGAINST ('Latvia')");

while ($col = mysql_fetch_assoc($aax)){

echo $col['skaits'];

}

 

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource

Link to comment
Share on other sites


×
×
  • Create New...