relational database - mysql: Find first father by single query in father son relation table -


I have a relational table of father and son ID, it has many relational tables and many users Here is the table, the original format of the table is here:

.......................... | Father_ID | Son_id ........................... | A. B .......................... | B C. .......................... | C. D | .......................... | D | E

Now I have to find the eldest grand father of any one of the sons I can achieve this goal by a MySQL query, or I have to use PHP Loop ?

itemprop = "text">

Your question is not clear, but if you are father_id of every father, who is a great grandfather:

Your table is the rows where "person [father_ID] person's father [son_id]" is. Write it in shortcode as as_father_of (father_id, son_id). Note that the short story is like a SQL table declaration. Aka FS, GS, GGG is in the original table_path_of If you want rows (ggs.is_father_id) where

  is_father_of (fs.father_id, fs.son_id) and is_father_of (gs.father_id, fs.father_id) and is_father_of (ggs.father_id, gs. Father_id)  

this is

  choose from is_father_of FS gg.is_father_id gs.son_id = fs.father_id is_father_of gs based on joining GGS is_father_of Combination ggs.son_id = Gs.father_id  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -