Re: retriving values from two tables

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

 



> Hi all,
>
> I am karthik. I am using using php with mysql. i am stuck with a qury. Pls
hep me out.
>
> i have two tables. Here is table with sample data
>
> Table Name : Links
>
> linkid                     header
> 1                           yahoo.com
> 2                           google.com
> 3                           php.net
> 4                           sai.org
> 5                           mysql.net
>
> Table Name : subLinks
>
> linkid                     childid
> 1                             2
> 3                             5
> 4                             3
>
> I want to fetch the linkid and header from links table based on condition
that i select only the main links. which are not under any link
>
> In our example it is
>
> 1 and 4
>
> Pls help out with the query..Its Urgent
>
> Thanks
>
> Jai Sairam
>
> Karthikeyan.S

How about:

SELECT l.linkid, l.header FROM Links l LEFT JOIN subLinks s ON l.linkid =
s.childid WHERE s.childid IS NULL

I think that'll work.

---John Holmes...


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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux