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
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;
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.