deansaddigh Posted January 7, 2010 Share Posted January 7, 2010 How can i join clients to enquires table so i can grab the email from the clients table heres the sql they are using. $query = dbExec("SELECT * FROM enquiries WHERE status = 'uncontacted' $searchSQL $filterSQL $limitBy"); somewhere in there i wanna join to clients as well Link to comment https://forums.phpfreaks.com/topic/187594-joining-tables/ Share on other sites More sharing options...
tomdchi Posted January 7, 2010 Share Posted January 7, 2010 I am totaly making up some field names of course and in order to join to tables you have to have something that is in both tables that you can use to join. For example, client id. Assuming that the clients table has a id field and the enquiries table has the client id as well you could do something like: "SELECT enquiries.*, clients.id, clients.firstname, clients.lastname, clients.email FROM enquiries, clients WHERE enquiries.status = 'uncontacted' AND enquiries.clientid = clients.id $searchSQL $filterSQL $limitBy"; Link to comment https://forums.phpfreaks.com/topic/187594-joining-tables/#findComment-990451 Share on other sites More sharing options...
Maq Posted January 7, 2010 Share Posted January 7, 2010 Have you taken a look at the MySQL manual for the JOIN sytax? http://dev.mysql.com/doc/refman/5.0/en/join.html Link to comment https://forums.phpfreaks.com/topic/187594-joining-tables/#findComment-990452 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.