Forum Moderators: coopster

Message Too Old, No Replies

SELECT FROM.please help!

         

m8fyu

10:36 pm on Sep 6, 2010 (gmt 0)

10+ Year Member



I'm new to PHP/MySQL and am rather stuck on something that I know is actually pretty easy. But for the life of me I can't seem to figure out how to get the data from one of my tables. Its been a long day and I'm hoping that tomorrow I might be a little more compus mentus and be able to figure this out...but just in case I really am stupid I thought I'd ask for some help from some pro's.

a user is browsing my site and ends up on the service information page. i need them to click on a link to open a new page showing the details of the boat that provides the service.

in my database i have the following 2 tables. there is a one-to-many relationship between my tables - one boat can have many services.

boats table:
boat_id

services table:
service_id
fk_boat_id

fk_boat_id is foreign key relating to boat_id

i'm passing a variable (service_id) and need to extract all columns from my boat table and display the data on my page. It seems pretty basic so I just don't know why I can't fathom it out. I'm totally stuck and could really do with a shove in the right direction. Please can anyone help?

johnblack

12:54 am on Sep 7, 2010 (gmt 0)



Off the top of my head

select boat_id
from boats
left outer join services on services.fk_boat_id = boats.boat_id
where services.service_id = $service_id

m8fyu

10:51 am on Sep 7, 2010 (gmt 0)

10+ Year Member



Thanks John

That work's a treat. I think this would have taken me some time to figure out so thanks very very much.

I love this place. If Carlsberg made websites...

m8fyu

10:52 am on Sep 7, 2010 (gmt 0)

10+ Year Member



Thanks John

That work's a treat. I think this would have taken me some time to figure out so thanks very very much.

I love this place. If Carlsberg made websites...