Jump to content

Simple sql problem - I think!


bluwe

Recommended Posts

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

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=233

SELECT table1.column1, table2.column2 FROM table1, table2, table3
  WHERE table1.column1 = table2.column1
  AND table1.column1 = table3.column1 AND table1.column=233;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.