0

I am joining tables using sql with the following query:

select * from table name1 a 
left join name2 b on b.ida = a.id
left join name3 c on c.idb  = b.id 

My doubt is my main table is name1 and left joining name2 table using foreign key. I am joining name3 table also where there is no relation between name1 and name3. Is it a good practise ?

Karanam Krishna
  • 365
  • 2
  • 16
  • It's not a bad thing. – sticky bit Apr 04 '20 at 06:54
  • 1
    Is what, exactly, a good practice? What did you learn googling about that? What choice have you got anyway? (Not rhetorical.) PS Querying is not based on FKs, PKs or other constraints. Tables are joined on conditions on columns. Tables represent relation(ship)s/associations. FKs are wrongly but frequently called "relation(ship)s". We do not need to know any to query & it doesn't matter whether they are any to query. They are for the DBMS to enforce integrity. – philipxy Apr 04 '20 at 07:00
  • 1
    Before considering posting please read the manual & google any error message or many clear, concise & precise phrasings of your question/problem/goal, with & without your particular strings/names & site:stackoverflow.com & tags; read many answers. If you post a question, use one phrasing as title. Reflect your research. See [ask] & the voting arrow mouseover texts. – philipxy Apr 04 '20 at 07:03

0 Answers0