Page 1 of 1
can any one explain this query to me??
Posted: Wed Sep 22, 2004 5:02 pm
by itsmani1
Code: Select all
<?php
$select = "SELECT sec.idnum AS 'ID Number', sec.lname AS 'Last Name', secy.fname AS 'First Name' FROM table WHERE (($search) LIKE '%$svalue%')) ORDER BY $order";
?>
can any one explain this query to me specially sec.idum etc, and
(($search)LIKE '%$values%')) ORDER BY $order";
i havn't used this type of query ever....
Posted: Wed Sep 22, 2004 5:19 pm
by Weirdan
it returns all rows where field $search is like $values and orders that resultset by field $order. All of them are variable, thus can be adjusted based on user input or something. sec.idnum won't work because there's no such table mentioned in FROM clause.
Posted: Wed Sep 22, 2004 6:07 pm
by itsmani1
Code: Select all
<?php
$select = "SELECT sec.idnum AS 'ID Number', sec.lname AS 'Last Name', secy.fname AS 'First Name' FROM (itable INNER JOIN linktable ON itable.policynumber = linktable.policynumber) INNER JOIN security ON linktable.agentid = sec.idnum WHERE (($search) LIKE '%$svalue%')) ORDER BY $order";
?>
Now this is the complete qyery. please tell me wot sec.idmun means and 2nd thing is
Code: Select all
FROM (itable INNER JOIN linktable ON itable.policynumber = linktable.policynumber) INNER JOIN security ON linktable.agentid = sec.idnum
wot is this???
Regards!!!!
Posted: Wed Sep 22, 2004 7:01 pm
by Breckenridge
sec.idnum is:
sec is a table name
idnum of a field in the table named sec
is more or less the same as:
when you use the AS var_name you are instructing the db engine to use var_name insted of the actual table field which is idnum that is all
to understand joins please visit:
http://dev.mysql.com/doc/mysql/en/JOIN.html
Posted: Wed Sep 22, 2004 7:19 pm
by itsmani1
Breckenridge wrote:sec.idnum is:
sec is a table name
idnum of a field in the table named sec
is more or less the same as:
when you use the AS var_name you are instructing the db engine to use var_name insted of the actual table field which is idnum that is all
to understand joins please visit:
http://dev.mysql.com/doc/mysql/en/JOIN.html
well thankx for the help now one more thing left that i donot know
Code: Select all
<?php
FROM (itable INNER JOIN linktable ON itable.policynumber = linktable.policynumber) INNER JOIN security ON linktable.agentid = sec.idnum
?>
Posted: Wed Sep 22, 2004 8:51 pm
by John Cartwright
from mysql_manual
INNER JOIN and , (comma) are semantically equivalent in the absence of a join condition: both will produce a Cartesian product between the specified tables (that is, each and every row in the first table will be joined onto all rows in the second table).