formulate nested select

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux