Re: [PHP-DB] retriving values from two tables

2002-11-19 Thread Shannon Johnston
I'm not clear on what you're considering the 'main links'. 

You can use the linkid value to match the header in the Links table to
the childid in the subLinks table.

SELECT Links.header, subLinks.childid FROM Links, subLinks WHERE
Links.linkid = subLinks.linkid;

This should return values like this:

-
| header  |  childid|
-
|  yahoo.com  | 2   |
|  php.net| 5   |
|  sai.org| 3   |
-

You could narrow down the results returned by adding WHERE
subLinks.childid = $value in your query.


Hope this helps!

Shannon Johnston



On Tue, 2002-11-19 at 10:22, karthikeyan wrote:
> 
> 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
> 
>  
> 
>  
> 
> 
> 
> -
> Do you Yahoo!?
> Yahoo! Web Hosting - Let the expert host your site


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




Re: [PHP-DB] retriving values from two tables

2002-11-19 Thread 1LT John W. Holmes
> 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




[PHP-DB] retriving values from two tables

2002-11-19 Thread karthikeyan

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

 

 



-
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site