Sunday, March 11, 2012

datagrid

hey all

i have 2 tables
1. Location (locid, name)
2. Product (pid, locid, productname, ...etc)

right now i do a select * from product where locid ='locid', and a datagrid with colums
ProductId | ProductName | AvailableIn

how do i do a select * from Location where locid ='locid' and show Location Name in the datagrid?

ProductId | ProductName | AvailableIn
123456 | testing | Somewhere (instead of the locid)

thankstry this. I haven't tested this, but should give you a good indication of what is needed...


SELECT *, L.Name AS "AvailableIn'
FROM Product P
INNER JOIN Location L
ON P.locid=L.locid
WHERE P.locid='locid'

Hope that helps!
KJ
(The INNER JOIN will list all products that have a corresponding entry on the Location table. If that column was optional, you can use a LEFT JOIN)|||It should probably be


SELECTP.*, L.Name AS 'AvailableIn'......

KJ