formulate nested select
| From: | PJ | Date: | Tue, 31 Mar 2009 01:25:52 +0000 |
| Subject: | formulate nested select | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-290871@lists.php.net to get a copy of this message | ||
I cannot find anything on google or the manuals/tutorials that gives
some kin of clear explanation of how to so nested selects with where or
whatever.
I have three tables: books, authors and book-authors.
I need to retrieve only those books whose author's names begin with A.
I have tried several maniipulations of where and select with select
subqueries and I cannot get results from the queries.
For example
"SELECT * FROM book b, book_authors c (SELECT id FROM author WHERE
LEFT(author.last_name = $Auth )) as a WHERE a.id = c.authID && b.id =
c.bookID ....<snip>
$Auth = A echoes as A
var_dump returns boolean false
and I get a warning - mysql_num_rows(): supplied argument is not valid....
It is obvious that the syntax is ok, but there is something here that I
do not understand.
It would appear that this should be something very simple, but I don't
see logic working here since I can not do this either
"SELECT * FROM book b, book_authors c, author a WHERE c.authID = (SELECT
a.id WHERE LEFT(a.last_name) = $Auth) && b.id = c.bookID ...
I would really appreciate some help & clarification.
TIA
--
unheralded genius: "A clean desk is the sign of a dull mind. "
-------------------------------------------------------------
Phil Jourdan --- pj@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com/andypantry.php