0

I want to join three tables (with many columns each). From the first table I need all columns. From the second and third table I only need a few columns each.

How can I join the three tables without having to type out all needed column names in my select statement? I understand that I will type out the needed column names for the 2nd and 3rd table. However, for the first table I would like to use select *.

3
  • Please provide a minimal reproducible example with sample data, desired results and your attempt. Also please tag your RDBMS. Commented May 1 at 10:04
  • 2
    FYI... its best practise to always type out all columns. Relying on select * often leads to future issues. Commented May 1 at 10:05
  • 3
    But the answer is probably just select t1.*, t2.col1, t2.col2 etc Commented May 1 at 10:06

1 Answer 1

1
SELECT p.*, c.description, s.company_name
from products p
join categories c on p.category_id = c.category_id
Join suppliers s on p.supplier_id = s.supplier_id
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.