PDA

View Full Version : Php query problem


mwm
08-16-2006, 02:21 PM
I have three tables
Table 1 name Customers

fields

id
lname
lot
community

Table 2 name csi

fields

csiid
id
contractors

Table 3 name Notes_tbl

field

noteid
id
notes

the common column is id in all tables

I need some way to query the db and get the following fields echoed back.

community, lot, contractor and notes. I tried to do a join on id but that didn't work. Any suggestion. Thank You

Fumigator
08-16-2006, 02:43 PM
You have the right idea, a join. Maybe you could post the query you tried and we can see why it didn't work.

mwm
08-16-2006, 03:04 PM
Below is the last one I tried that didn't work. I appreicate you taking a look.

$mysql = 'select customers.id, customers.lot,csi.id,csi.contractor from customers,csi where customers.community = '$community' and customers.id = csi.id ';

Fumigator
08-16-2006, 05:01 PM
You've got problems with your quotes, but other than that your syntax is correct. Make sure you encapsulate the string with double quotes if you need to use single quotes as part of the query.

There's really no need to select the id twice either, but no big deal.


$mysql = "select customers.id, customers.lot,csi.id,csi.contractor from customers,csi where customers.community = '$community' and customers.id = csi.id";

mwm
08-16-2006, 05:38 PM
Thanks again