39.8k views
4 votes
What is the SQL query to select data from tables a, b, and c where col1 is equal to col2 and col2 is equal to col3?

User PSSGCSim
by
8.2k points

1 Answer

5 votes

Final answer:

The SQL query to select data from tables a, b, and c with specified column equivalences would use JOIN clauses.

Step-by-step explanation:

The SQL query to select data from tables a, b, and c where col1 is equal to col2 and col2 is equal to col3 could look like this:

SELECT *
FROM a
JOIN b ON a.col1 = b.col2
JOIN c ON b.col2 = c.col3;

In this case, none of the tables is "more correct" than the others; it's about how they are related to each other. Data can be grouped differently based on the relationships between tables, which might lead to more efficient queries or more intuitive data organization.

These are some advantages to different groupings. I didn't switch between tables when answering because the requirement explicitly states all tables must be involved with specific join conditions.

User Peterhack
by
7.4k points