bluwe Posted November 15, 2006 Share Posted November 15, 2006 I want to select columns from three different tables where the customer_id column that exists on all three tables contains a certain value. I know you can go about it like this:SELECT table1.column1, table2.column2 FROM table1, table2, table3 WHERE table1.column1 = table2.column1 AND table1.column1 = table3.column1;But I already have the customer_id set as a variable and obviously I only want 1 row to be returned as the result of the query. Any ideas?Thanks!! Link to comment https://forums.phpfreaks.com/topic/27369-simple-sql-problem-i-think/ Share on other sites More sharing options...
exploo Posted November 15, 2006 Share Posted November 15, 2006 just checking if i got the problem right.You have a custumer_id, lets say its 233.You want to select columns from three table where all the tables has costumer_id=233SELECT table1.column1, table2.column2 FROM table1, table2, table3 WHERE table1.column1 = table2.column1 AND table1.column1 = table3.column1 AND table1.column=233; Link to comment https://forums.phpfreaks.com/topic/27369-simple-sql-problem-i-think/#findComment-125246 Share on other sites More sharing options...
bluwe Posted November 16, 2006 Author Share Posted November 16, 2006 Can't seem to get that working - I didn't think you could have two AND statements in a select statement... Link to comment https://forums.phpfreaks.com/topic/27369-simple-sql-problem-i-think/#findComment-125642 Share on other sites More sharing options...
bluwe Posted November 16, 2006 Author Share Posted November 16, 2006 My mistake - dodgy data - it works a treat! Thanks mate!! Link to comment https://forums.phpfreaks.com/topic/27369-simple-sql-problem-i-think/#findComment-125647 Share on other sites More sharing options...
exploo Posted November 16, 2006 Share Posted November 16, 2006 Yeah, thougt so. You can have as many AND as you wish/need :) Link to comment https://forums.phpfreaks.com/topic/27369-simple-sql-problem-i-think/#findComment-125650 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.